https://docs.djangoproject.com/en/dev/topics/signals/#preventing-
duplicate-signals
I was confused what parameters I could give to the @receiver decorator.
The docs just say that it takes one parameter, the signal:
{{{
@receiver(request_finished)
def my_callback(sender, **kwargs):
print("Request finished!")
}}}
But I think it should show:
{{{
@receiver(request_finished, **kwargs)
def my_callback(sender, **kwargs):
print("Request finished!")
}}}
And explain that kwargs can be any of the arguments that you can pass to a
manual connection. I learned this by looking at the code, which is very
simple:
https://docs.djangoproject.com/en/dev/_modules/django/dispatch/dispatcher/#receiver
The reason this came up for me was that I was trying to figure out how to
add a dispatch_uid parameter to the @receiver decorator, and it's not
documented how to do so (ya just add it).
Would some tweaks to the docs along these lines be welcomed?
--
Ticket URL: <https://code.djangoproject.com/ticket/33909>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by David Sanders):
> Would some tweaks to the docs along these lines be welcomed?
Hi Mike,
Yes documentation PRs are always welcome. Just FYI for minor documentation
updates such as this you can submit a PR without creating a ticket. :)
Refs:
- https://docs.djangoproject.com/en/4.1/internals/contributing/writing-
code/submitting-patches/#typo-fixes-and-trivial-documentation-changes
- Documentation on how to update the documentation:
https://docs.djangoproject.com/en/4.1/internals/contributing/writing-
documentation/
--
Ticket URL: <https://code.djangoproject.com/ticket/33909#comment:1>
* type: New feature => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Agreed, we should at least correct the signature. Would you like to
prepare a patch?
--
Ticket URL: <https://code.djangoproject.com/ticket/33909#comment:2>
* owner: nobody => badziyoussef
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/33909#comment:3>
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
Comment:
[https://github.com/django/django/pull/15961 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/33909#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"0cbbed49f4fbe60ddf9b452b310815708a64cc64" 0cbbed49]:
{{{
#!CommitTicketReference repository=""
revision="0cbbed49f4fbe60ddf9b452b310815708a64cc64"
Fixed #33909 -- Corrected django.dispatch.receiver() signature.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33909#comment:5>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"bee09df39fe0734eb2388a2b3439436796592820" bee09df3]:
{{{
#!CommitTicketReference repository=""
revision="bee09df39fe0734eb2388a2b3439436796592820"
[4.1.x] Fixed #33909 -- Corrected django.dispatch.receiver() signature.
Backport of 0cbbed49f4fbe60ddf9b452b310815708a64cc64 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33909#comment:6>