#26664 closed New feature (wontfix)
Support of model_object.delete(cascade=True)
Reported by: | Sven R. Kunze | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I couldn't find anything via the search on this topic (maybe because its keywords are too generic).
Even though we have on_delete=PROTECTED on several models fields for a reason, there are circumstances where we want to circumvent this restriction also for a reason.
Would this be valuable addition to django?
Change History (3)
comment:1 by , 8 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 8 years ago
Hi Tim. I know that it might be dangerous. However, the reason why I suggest this feature is that we needed it in a backwards migration. I.e. it removes some data that has been created by its corresponding forward migration. In this case, we are 110% sure that it does not delete anything more than necessary.
Overriding Model.delete()
does not help in this case as it is NOT the original Model but a fake migration model.
We already have a helper function that carries out this deletion manually but we thought that a Django-provided way would be much cleaner.
This seems a bit dangerous to me. In particular, there's no way to control how far or to which relations the deletions will cascade. I think it's safer to explicitly handle the deletions in a use case like this. Of course, you can also override the
Model.delete()
method to have whatever behavior you like.If you can find consensus on the DevelopersMailingList to add something like this, I'll be happy to reopen the ticket.