Opened 7 years ago

Closed 7 years ago

#28169 closed Bug (invalid)

Unable to disconnect signal

Reported by: James Addison Owned by: nobody
Component: Database layer (models, ORM) Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I am looking to disconnect the post_init signal in a management command due to exceptions it raises in my scenario. My disconnect looks like this:

signals.post_init.disconnect(ImageField.update_dimension_fields, sender=Bug)

If I'm doing something wrong, I'd love to know what.

Digging in a bit, it's caused by the fact that the lookup key generated in the .connect() at differs from the one generated in .disconnect() at

Maybe related to #22657. See the attached project to reproduce.

Attachments (1) (13.2 KB) - added by James Addison 7 years ago.
Project demonstrating the issue.

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by James Addison

Attachment: added

Project demonstrating the issue.

comment:1 Changed 7 years ago by James Addison

Ok, so I found a way to do what I needed, but I'm not sure it 'resolves' this bug report, as it seems like a truly convoluted way to disconnect such a signal. The following will successfully disconnect the signal:

signals.post_init.disconnect(Bug._meta.get_field('image').update_dimension_fields, sender=Bug)

I will leave it to the core team to decide.

Last edited 7 years ago by James Addison (previous) (diff)

comment:2 Changed 7 years ago by Simon Charette

Resolution: invalid
Status: newclosed

Hello James,

Glad you managed to achieve what you were after.

Since the actual receiver is the update_dimension_fields method bound to the field instance, and not the unbound ImageField.update_dimension_fields function, it makes sense that you must pass the former and not the latter.

Since disconnecting such signal receiver is not a common use case I don't believe it's worth making this any simpler. I suggest you use our support channels to get help with these kind of issues in the future to get assistance faster and gather feedback about whether or not it's worth opening an issue about it. Thanks!

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