A pre/post batch_delete signal would be useful for the usage you describe. There would likely be confusion with its usage because unlike post_delete, the batch_delete signals would not be able to provide actual records. The best it could do would be to provide the queryset and the deletion count on the post. The topic of batch deletion signaling has come up before, but I don't remember the outcome (or whether it was on here or IRC). I'll try to find it and report back when I get to a more capable device.
Regards, Michael Manfre On Thu, May 7, 2015 at 7:36 PM, Antoine Catton <acat...@fusionbox.com> wrote: > Hello, > > django-treebeard [1] has an optimized batch deletion for its models. [2] > > The main reason is because post_delete signals are called for each > objects. And custom deletion in treebeard can be done in batch. > > I was reading Django's code [3] and it looks like there's no way to hook > into _raw_delete() or DeleteQuery.delete_batch(). > > The only way is to hook into signals.post_delete. > > This causes problems if we have something like this: > > class A(treebeard.MP_Tree): > b = ForeignKey('B') > > class B(models.Model): > a = IntegerField() > > If we run: > B.objects.filter(expression).delete() > Because Treebeard is overriding A.objects.delete(), the custom delete() > will never be called on the tree, and the tree will be inconsistent. > > One solution I can think of, would be to add a pre/post batch_delete > signal. But I'm open to any other solution. > > > [1] <http://code.tabo.pe/django-treebeard/src> > [2] < > http://code.tabo.pe/django-treebeard/src/04ca69b7daf6390bb2130305cf1325df486d6b7e/treebeard/mp_tree.py?at=default#cl-51 > > > [3] < > https://github.com/django/django/blob/3baebf52aa0850de3ebadcbe1eda7e6e9a2c6c44/django/db/models/deletion.py#L284 > > > > -- > Antoine Catton > Software Engineer at Fusionbox, Inc. > <https://www.fusionbox.com/> > > -- > 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 django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at http://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/554BF717.50503%40fusionbox.com > . > For more options, visit https://groups.google.com/d/optout. > -- GPG Fingerprint: 74DE D158 BAD0 EDF8 keybase.io/manfre -- 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 django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAGdCwBvZ2qE4VE8ZgzCOsAAgbQvwe6LCB3PULN%3Dc337pniZC4Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.