英文:
What is the meaning of "Model.delete() isn't called on related models" in Django Doc
问题
我正在阅读Django关于model fields和models.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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论