Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#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 David Sanders, 2 years ago

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:

comment:2 by Mariusz Felisiak, 2 years ago

Triage Stage: UnreviewedAccepted
Type: New featureCleanup/optimization

Agreed, we should at least correct the signature. Would you like to prepare a patch?

comment:3 by badziyoussef, 2 years ago

Owner: changed from nobody to badziyoussef
Status: newassigned

comment:4 by Mariusz Felisiak, 2 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 0cbbed49:

Fixed #33909 -- Corrected django.dispatch.receiver() signature.

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

In bee09df3:

[4.1.x] Fixed #33909 -- Corrected django.dispatch.receiver() signature.

Backport of 0cbbed49f4fbe60ddf9b452b310815708a64cc64 from main

Note: See TracTickets for help on using tickets.
Back to Top