[Django] #26664: Support of model_object.delete(cascade=True)

41 views
Skip to first unread message

Django

unread,
May 25, 2016, 7:33:16 AM5/25/16
to django-...@googlegroups.com
#26664: Support of model_object.delete(cascade=True)
----------------------------------------------+--------------------
Reporter: srkunze | Owner: nobody
Type: New feature | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
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?

--
Ticket URL: <https://code.djangoproject.com/ticket/26664>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 26, 2016, 1:21:51 PM5/26/16
to django-...@googlegroups.com
#26664: Support of model_object.delete(cascade=True)
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_docs: => 0
* resolution: => wontfix
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/26664#comment:1>

Django

unread,
May 27, 2016, 8:28:48 AM5/27/16
to django-...@googlegroups.com
#26664: Support of model_object.delete(cascade=True)
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody

Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by srkunze):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/26664#comment:2>

Django

unread,
May 27, 2016, 8:50:29 AM5/27/16
to django-...@googlegroups.com
#26664: Support of model_object.delete(cascade=True)
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody

Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by srkunze):

Proposal on DevelopersMailingList: https://groups.google.com/forum/#!topic
/django-developers/Rr0cX1ZEE-Y

--
Ticket URL: <https://code.djangoproject.com/ticket/26664#comment:3>

Reply all
Reply to author
Forward
0 new messages