Django signals: receiver and proxy model?

I set the receiver to a signal post_save, and I was hoping to catch signals for all the proxies of my model by setting the sender to the main model, but it doesn't seem to work:

class MyObject(models.Model):
    ....

class MyObjectProxy(MyObject):

    class Meta:
        proxy = True

# The receiver
# How to avoid writing another one for sender=MyObjectProxy ?
@receiver(post_save, sender=MyObject)
...

My receiver does not start when this happens:

obj = MyObjectProxy()
obj.save()

This is normal? Should I install a receiver for each proxy? Can I install senderin the list of models?

Thank.

+4
source share
1 answer

At the moment, I believe that the list of models is the only working way. There is an open discussion about this particular issue.

+1
source

Source: https://habr.com/ru/post/1532210/


All Articles