“Model.delete() isn’t called on related models” 在Django文档中的含义是什么?

huangapple go评论101阅读模式
英文:

What is the meaning of "Model.delete() isn't called on related models" in Django Doc

问题

我正在阅读Django关于model fieldsmodels.CASCADE的文章。我不理解这个短语:

> Model.delete() 在相关模型上不被调用

models.CASCADE 意味着在目标对象删除时要删除相关对象,那么 "在相关模型上不被调用" 是什么意思?

请为我解释一下。

英文:

I was reading Django's article on model fields and models.CASCADE. I don't understand this phrase:

> Model.delete() isn’t called on related models

models.CASCADE means that related objects to delete when the target object deleted ,so what is the meaning of "isn't called on related models"?

Please explain that for me.

答案1

得分: 1

以下是翻译好的部分:

如果您阅读后面的部分,可能更清楚,但是预删除和后删除信号将发送给所有已删除的对象。这意味着Django将删除这些对象,但不会调用这些对象的删除方法,并通过delete_batch方法删除它们。它仅会为该对象触发预删除和后删除信号。

英文:

If your read the part after its maybe more clearly but the pre_delete and post_delete signals are sent for all deleted objects. So what this means is Django will delete the objects but won't call the delete method of those objects -and delete them by delete_batch method-. It will only fire the pre_delete and post_delete signals for that object.

huangapple
  • 本文由 发表于 2020年1月3日 21:56:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59579820.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定