Hi Sven, I agree with Tim about the fact such an option could be dangerous as you can't control the extent of the cascade.
We removed the depth parameter of `QuerySet.select_related()` method for similar reasons and in this case you only ended up with a slow query not possibly purged data. They're have been a couple of issues reported related to cascade deletion in the past and most of the affected users we're saved by the enforced constraints at the database level. I'm afraid the addition of such an option could lead unexperienced developers to always pass cascade=True when they encounter a foreign key constraint check failure. > overriding Model.delete() does not help as we needed it (this time) in a backward > migration to clean up what has been created in a forward migration. Migrations > don't expose model-overriden functions. Could simply define this feature a as imported function that takes a model instance or define a model mixin witht the overriden `delete(cascade)` method? The autodetector should include it in the model bases. Cheers, Simon Le vendredi 27 mai 2016 08:49:42 UTC-4, Sven R. Kunze a écrit : > > Hi everybody, > > That's my first proposal for Django, so I hope it's in the right shape. :) > > > Even though we have on_delete=PROTECTED on several models fields for a > very good reason, there are circumstances where we want to circumvent this > restriction for a very good reason, too. And we are 110% sure that this is > a safe operation. > > Tim already suggested to do this manually but this is very tedious for > larger database structure as we have. We already wrote a generic function > which provides that capability but we would appreciate a Django-bulitin > functionality for this as we duplicate some Django-internal code. > > > Note 1: overriding Model.delete() does not help as we needed it (this > time) in a backward migration to clean up what has been created in a > forward migration. Migrations don't expose model-overriden functions. > Note 2: discussion started here: > https://code.djangoproject.com/ticket/26664 > > > Would this be valuable addition to Django? > > > Best, > Sven > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/27448ccf-2990-441d-affd-a25c46ff0f10%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
