#33909 closed Cleanup/optimization (fixed)
Signals docs omits **kwargs param to @receiver decorator?
Reported by: | Mike Lissner | Owned by: | badziyoussef |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | signals |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Looking at the Signals docs:
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?
Change History (6)
comment:1 by , 2 years ago
comment:2 by , 2 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | New feature → Cleanup/optimization |
Agreed, we should at least correct the signature. Would you like to prepare a patch?
comment:3 by , 2 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
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: