[Django] #36600: Misleading wording in description of dispatch_uid

8 views
Skip to first unread message

Django

unread,
Sep 9, 2025, 11:01:07 AM (14 days ago) Sep 9
to django-...@googlegroups.com
#36600: Misleading wording in description of dispatch_uid
---------------------------------+-----------------------------------------
Reporter: Roman Donchenko | Type: Bug
Status: new | Component: Documentation
Version: 5.2 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
The [https://docs.djangoproject.com/en/dev/topics/signals/#preventing-
duplicate-signals documentation for signals] currently says the following:

> In some circumstances, the code connecting receivers to signals may run
multiple times. This can cause your receiver function to be registered
more than once, and thus called as many times for a signal event. For
example, the `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.

There are a few problems here. First, the last sentence just seems wrong.
Importing a module multiple times does not run its code multiple times;
therefore it should be completely safe to do this with a module containing
signal handlers.

It seems that `dispatch_uid` was originally introduced to work around a
problem where a module would be imported multiple times ''with different
names'' (#3951), but that problem has long been fixed (#15372).

Moreover, even if the signal handler is registered directly in `ready()`,
and `ready()` is called multiple times, it appears that in many cases
`dispatch_uid` is still unnecessary. When it's unspecified, the
[https://github.com/django/django/blob/46fdeb1373aa7e9089d14440987444493cc9c2e0/django/dispatch/dispatcher.py#L13-L16
implementation] effectively uses a default `dispatch_uid` of
`(id(target.__self__), id(target.__func__))` when the target is a method,
or `id(target)` in all other cases. This means that code like this should
work fine:

{{{#!python
def my_handler():
...

class MyAppConfig(AppConfig):
def ready(self):
my_signal.connect(my_handler)
}}}

However, this is not explained in the docs.

Because of these problems, the docs end up encouraging users to use
`dispatch_uid` everywhere, even though it's really only necessary in some
specific cases (i.e., when the handler is not a global function or a
static/class method of a global class). I think they should be edited to
explain the use case more clearly.
--
Ticket URL: <https://code.djangoproject.com/ticket/36600>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 11, 2025, 10:32:41 PM (11 days ago) Sep 11
to django-...@googlegroups.com
#36600: Misleading wording in description of dispatch_uid
---------------------------------+--------------------------------------
Reporter: Roman Donchenko | Owner: (none)
Type: Bug | Status: new
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by Samriddha Kumar Tripathi):

I’d like to work on this ticket. I’ll review the current signals
documentation and propose edits to clarify when dispatch_uid is necessary,
based on Django’s internal deduplication logic.
--
Ticket URL: <https://code.djangoproject.com/ticket/36600#comment:1>

Django

unread,
Sep 13, 2025, 1:45:09 PM (10 days ago) Sep 13
to django-...@googlegroups.com
#36600: Misleading wording in description of dispatch_uid
---------------------------------+--------------------------------------
Reporter: Roman Donchenko | Owner: (none)
Type: Bug | Status: new
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by its-me-maady):

Can i work on this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/36600#comment:2>

Django

unread,
Sep 16, 2025, 3:58:46 AM (7 days ago) Sep 16
to django-...@googlegroups.com
#36600: Misleading wording in description of dispatch_uid
---------------------------------+--------------------------------------
Reporter: Roman Donchenko | Owner: Luna
Type: Bug | Status: assigned
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Luna):

* owner: (none) => Luna
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36600#comment:3>

Django

unread,
Sep 16, 2025, 10:02:22 AM (7 days ago) Sep 16
to django-...@googlegroups.com
#36600: Misleading wording in description of dispatch_uid
---------------------------------+--------------------------------------
Reporter: Roman Donchenko | Owner: Luna
Type: Bug | Status: assigned
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by Samriddha Kumar Tripathi):

Hey Luna, I’m still learning my way around Django, but I’m really
interested in this topic. Would love to see your patch once it’s
ready—just curious to learn from how you approach it!
--
Ticket URL: <https://code.djangoproject.com/ticket/36600#comment:4>

Django

unread,
Sep 16, 2025, 10:08:14 AM (7 days ago) Sep 16
to django-...@googlegroups.com
#36600: Misleading wording in description of dispatch_uid
---------------------------------+--------------------------------------
Reporter: Roman Donchenko | Owner: Luna
Type: Bug | Status: assigned
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Samriddha Kumar Tripathi):

* cc: Samriddha Kumar Tripathi (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/36600#comment:5>

Django

unread,
Sep 17, 2025, 6:09:42 AM (6 days ago) Sep 17
to django-...@googlegroups.com
#36600: Misleading wording in description of dispatch_uid
---------------------------------+------------------------------------
Reporter: Roman Donchenko | Owner: Luna
Type: Bug | Status: assigned
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Sarah Boyce):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/36600#comment:6>
Reply all
Reply to author
Forward
0 new messages