I have a proxy model.
class ProxyModel(ParentModel):
objects = ProxyModelManager()
class Meta:
proxy = True
I’m trying to define my proxy model as a sender.
@receiver(post_save, sender=core_models.ProxyModel)
def test_receiver(sender, instance, **kwargs):
print("test receiver")
But the function is not called after the model is saved.
Is it possible to define proxy model as sender? If so how can I do ?
Thanks.
I’m guessing not.
Whether it’s intended to be read this way for your question or not, there’s this sentence within the Proxy model docs:
You can create, delete and update instances of the proxy model and all the data will be saved as if you were using the original (non-proxied) model.
To me, that says that the original model is the initiator of any signals.
I noticed that, If I save the object like so,
>>> from core.models Import ProxyModel
>>> p = ProxyModel.objects.get(name="Object Name")
>>> p.save()
>>> test receiver
The function is being called and prints “test receiver”. But, If I save same object via admin panel through parent model, It doesn’t.
1 Like