I use pre_save and post_save signals in my app with many receivers on them. For example :
@receiver(post_save, sender=SrdRevisionDocument)
@receiver(post_save, sender=SrdRevisionWording)
@receiver(post_save, sender=SrdRevisionAcronym)
@receiver(post_save, sender=SrdRevisionRevision)
@receiver(post_save, sender=SrdRevisionTableRequest)
@receiver(post_save, sender=SrdRevisionTable)
def handle_added_or_edited_element(sender, instance, **kwargs):
... content of the signal
However, in some case, I need to disconnect the signal to have only the usual behavior of the save()
method.
I tried the simple method in Django documentation Signal.disconnect(receiver=None, sender=None, dispatch_uid=None)
but it doesn’t works with multiple receivers.
Also, I’ve tried some solutions from StackOverflow, like Context Manager
but none seems to work with multiple receivers (i.e., Disconnect signals for models and reconnect in django).
I know I’m not the only one facing this issue, but I didn’t found a solution.