summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwrwrwr <git@wr.waw.pl>2014-11-27 11:22:23 -0500
committerTim Graham <timograham@gmail.com>2014-11-27 11:22:36 -0500
commitd66bda60590daabe21f60a532a613a31a10fedbd (patch)
treef82410e6adc6a3b1a1b441be89ba4b0c5ced0771
parenta15aba66f2fc650f70a791fb7fa880cf85cb1229 (diff)
Added notes on registering signals in ready() and using dispatch_uid.
Refs #23641.
-rw-r--r--docs/ref/signals.txt9
-rw-r--r--docs/topics/signals.txt7
2 files changed, 16 insertions, 0 deletions
diff --git a/docs/ref/signals.txt b/docs/ref/signals.txt
index d1f5f3c78f..b41b3f63dd 100644
--- a/docs/ref/signals.txt
+++ b/docs/ref/signals.txt
@@ -509,6 +509,15 @@ For example, you could register a callback in an
def ready(self):
post_migrate.connect(my_callback, sender=self)
+.. note::
+
+ If you provide an :class:`~django.apps.AppConfig` instance as the sender
+ argument, please ensure that the signal is registered in
+ :meth:`~django.apps.AppConfig.ready`. ``AppConfig``\s are recreated for
+ tests that run with a modified set of :setting:`INSTALLED_APPS` (such as
+ when settings are overridden) and such signals should be connected for each
+ new ``AppConfig`` instance.
+
post_syncdb
-----------
diff --git a/docs/topics/signals.txt b/docs/topics/signals.txt
index cb1d067c3c..dab29ba4ec 100644
--- a/docs/topics/signals.txt
+++ b/docs/topics/signals.txt
@@ -146,6 +146,13 @@ Now, our ``my_callback`` function will be called each time a request finishes.
versions of Django, signal registration usually happened in the
``models`` module.
+.. note::
+
+ The :meth:`~django.apps.AppConfig.ready` method may be executed more than
+ once during testing, so you may want to :ref:`guard your signals from
+ duplication <preventing-duplicate-signals>`, especially if you're planning
+ to send them within tests.
+
.. _connecting-to-specific-signals:
Connecting to signals sent by specific senders