[3.1.x] Fixed #24816 -- Clarified docs about preventing duplicate signals.

Backport of 639142e24d from master
This commit is contained in:
Jason Held 2020-06-30 22:54:39 -04:00 committed by Mariusz Felisiak
parent eae78a363b
commit 703256fc68
1 changed files with 5 additions and 1 deletions

View File

@ -188,7 +188,11 @@ Preventing duplicate signals
In some circumstances, the code connecting receivers to signals may run In some circumstances, the code connecting receivers to signals may run
multiple times. This can cause your receiver function to be registered more multiple times. This can cause your receiver function to be registered more
than once, and thus called multiple times for a single signal event. than once, and thus called as many times for a signal event. For example, the
:meth:`~django.apps.AppConfig.ready` method may be executed more than once
during testing. More generally, this occurs everywhere your project imports the
module where you define the signals, because signal registration runs as many
times as it is imported.
If this behavior is problematic (such as when using signals to If this behavior is problematic (such as when using signals to
send an email whenever a model is saved), pass a unique identifier as send an email whenever a model is saved), pass a unique identifier as