diff options
| author | Dmitry Medvinsky <dmedvinsky@gmail.com> | 2012-06-08 14:00:51 +0400 |
|---|---|---|
| committer | Florian Apolloner <florian@apolloner.eu> | 2012-06-23 16:31:16 +0200 |
| commit | d4da08375b634544b95859d4d4667b8f05e3a29a (patch) | |
| tree | cdd83ab9b4a15ef938c9811c3e5f02edaf34a4c2 /docs | |
| parent | 946d3d9f84ea7979a4abf0857e4aa7ee33576303 (diff) | |
Fixed #18454 -- Added ability to pass a list of signals to `receiver`.
Added ability to use receiver decorator in the following way:
@receiver([post_save, post_delete], sender=MyModel)
def signals_receiver(sender, **kwargs):
...
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/1.5.txt | 3 | ||||
| -rw-r--r-- | docs/topics/signals.txt | 13 |
2 files changed, 13 insertions, 3 deletions
diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt index 719433f8fe..2f20f5f9f9 100644 --- a/docs/releases/1.5.txt +++ b/docs/releases/1.5.txt @@ -103,6 +103,9 @@ Django 1.5 also includes several smaller improvements worth noting: * In the localflavor for Canada, "pq" was added to the acceptable codes for Quebec. It's an old abbreviation. +* The :ref:`receiver <connecting-receiver-functions>` decorator is now able to + connect to more than one signal by supplying a list of signals. + Backwards incompatible changes in 1.5 ===================================== diff --git a/docs/topics/signals.txt b/docs/topics/signals.txt index 3ef68316a9..fa668cc8c7 100644 --- a/docs/topics/signals.txt +++ b/docs/topics/signals.txt @@ -52,10 +52,10 @@ called when the signal is sent by using the :meth:`.Signal.connect` method: .. method:: Signal.connect(receiver, [sender=None, weak=True, dispatch_uid=None]) - + :param receiver: The callback function which will be connected to this signal. See :ref:`receiver-functions` for more information. - + :param sender: Specifies a particular sender to receive signals from. See :ref:`connecting-to-specific-signals` for more information. @@ -129,10 +129,17 @@ receiver: Now, our ``my_callback`` function will be called each time a request finishes. +Note that ``receiver`` can also take a list of signals to connect a function +to. + .. versionadded:: 1.3 The ``receiver`` decorator was added in Django 1.3. +.. versionchanged:: 1.5 + +The ability to pass a list of signals was added. + .. admonition:: Where should this code live? You can put signal handling and registration code anywhere you like. @@ -182,7 +189,7 @@ Preventing duplicate signals In some circumstances, the module in which you are connecting signals may be imported multiple times. This can cause your receiver function to be registered more than once, and thus called multiples times for a single signal -event. +event. If this behavior is problematic (such as when using signals to send an email whenever a model is saved), pass a unique identifier as |
