#6915 closed (fixed)
object.some_set.all().delete() does not call the delete method on some object
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | qsrf-cleanup delete | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
If you override an objects delete method:
object.something_set.all().delete()
does not do the same as:
for something in object.something_set.all(): something.delete()
The new delete method is never called and hence any associated cleanup or audit code are never called. This comes to light when you delete an object which in turn deletes related objects.
Attachments (4)
Change History (12)
by , 17 years ago
Attachment: | 6915.naive-patch.diff added |
---|
comment:1 by , 17 years ago
Component: | Core framework → Database wrapper |
---|---|
Has patch: | set |
Needs documentation: | set |
Patch needs improvement: | set |
by , 17 years ago
Attachment: | 6915.naive-patch.2.diff added |
---|
by , 17 years ago
Attachment: | 6915.regressiontest.diff added |
---|
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:3 by , 17 years ago
Keywords: | qsrf-cleanup added |
---|
comment:4 by , 17 years ago
milestone: | → 1.0 |
---|
comment:5 by , 17 years ago
Description: | modified (diff) |
---|
by , 16 years ago
Attachment: | 6915.naive.r7787.diff added |
---|
comment:6 by , 16 years ago
Component: | Database wrapper → Documentation |
---|---|
Has patch: | unset |
Patch needs improvement: | unset |
Triage Stage: | Design decision needed → Accepted |
This is only open until I (or somebody else) writes a documentation patch. The delete()
method is primarily a mass-SQL operation, just like update()
. However, because I suspect we sometimes do call delete()
on some of the auxilliary objects, I'd like to try and document when that happens in case somebody does write a custom method. Really, though, there shouldn't be many custom delete()
methods. Performing secondary actions for a delete is better done via post-delete
signal handlers. Calling the delete()
method on every object that has one will just slow things down.
So the resolution here is a docs patch, nothing more.
comment:7 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
#7360 might be a duplicate.
How should this be implemented? (http://groups.google.at/group/django-developers/browse_thread/thread/8807069717e78370)