On 27 heinä, 18:50, Jeremy Dunck <[email protected]> wrote: > Ah, yes, hmm. Actually, it *is* possible to get signals attached to > the through. > > from django.db.models import signals > signals.pre_delete.connect(handler, sender=Voter.districts.through) > > So I don't think we can even take that shortcut on just the autom2m > tables. As the "signals maintainer", let me just say: damn, they > cause a lot of trouble. :-) > > OK, it would be easy enough to add a signal method to see if there are > signals attached for a given sender (model in this case). > > I'll work up a patch for the simplified case of auto-intermediates and > no receivers for pre/post delete and see where that gets us in > performance. > > Do we already have machinery in place for "does this model have the > potential to cascade"? I see Collector uses > ._meta.get_all_related_objects, but that seems pretty heavy for the > simple need to branch depending on "yes or no".
This issue came up in #django-dev recently and I decided to do something about this. I think I have something commit-quality done for this, see: https://code.djangoproject.com/ticket/18676#comment:2 and https://github.com/akaariai/django/compare/fast_delete The code has full fast path support - we can bulk delete in the DB if there are no signals, and no cascades further (including parent models and generic foreign keys). I will be pushing this into 1.5 before feature freeze if no blocker issues arise. - Anssi -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
