Skip to main content

receiver

A decorator for connecting receivers to signals. Used by passing in the signal (or list of signals) and keyword arguments to connect::

@receiver(post_save, sender=MyModel)
def signal_receiver(sender, **kwargs):
...

@receiver([post_save, post_delete], sender=MyModel)
def signals_receiver(sender, **kwargs):
...
def receiver(
signal: Union[Signal, List[Signal], Tuple[Signal]],
**kwargs: dict
) - > function

A decorator for connecting receivers to signals. Used by passing in the signal (or list of signals) and keyword arguments to connect.

Parameters

NameTypeDescription
signalUnion[Signal, List[Signal], Tuple[Signal]]The signal instance or a collection of signal instances to which the decorated function will be connected.
**kwargsdictConfiguration options passed directly to the signal's connect method, such as 'sender' to filter which objects trigger the receiver.

Returns

TypeDescription
functionA decorator function that wraps the signal handler and registers it with the specified signals.