#13534 closed (invalid)
m2m_changed signal doesn't call receiver
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.2-beta |
Severity: | Keywords: | m2m_save, dispatch, signal | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
For some reason or another the m2m_changed signal does not call the receiver.
A rough models.py similar to my code:
class SomeContent(models.Model): sites = models.ForeignKey(Site) def m2m_handler(sender, instance, action, reverse, model, pk_set, **kwargs): raise NotImplementedError models.signals.m2m_changed.connect(m2m_handler, SomeContent) >>> sc = SomeContent() >>> sc.save() >>> sc.sites.add(Site.objects.get_current()) # Here you would expect a "NotImplementedError" >>>
It seems the signal loses all receivers in django.dispatch.dispatcher.Signal._line_receivers
line 215.
Note:
See TracTickets
for help on using tickets.
The sample code is invalid on two counts:
{{
models.signals.m2m_changed.connect(m2m_handler, SomeContent.sites.through)
}}