#32515: m2m_changed signal not received with custom through model
-------------------------------------+-------------------------------------
Reporter: leon | Owner: nobody
hughes |
Type: Bug | Status: new
Component: Database | Version: 2.2
layer (models, ORM) | Keywords: m2m_changed,
Severity: Normal | signals
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Consider the following models:
{{{
class Game(models.Model):
participants = models.ManyToManyField(
to='card_users.UserProfile',
related_name='card_games',
through='cardgame.GameThroughModel',
)
class GameThroughModel(models.Model):
game = models.ForeignKey(
to='card_game.Game',
on_delete=models.CASCADE,
)
participant = models.ForeignKey(
to='card_users.UserProfile',
on_delete=models.CASCADE,
)
class UserProfile(models.Model):
user = models.OneToOneField(
to=settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='profile',
)
}}}
I have a receiver set up to perform further actions when new participants
are added using m2m_changed:
{{{
@receiver(m2m_changed, sender=Game.participants.through,
dispatch_uid='create_initial_round', weak=False)
def create_initial_round(sender, instance, action, **kwargs):
print(f"{sender}, {instance}, {action}")
}}}
The m2m_changed signal is not received. When a standard manytomany model
relation is used ie.:
{{{
class Game(models.Model):
participants = models.ManyToManyField(
to='card_users.UserProfile',
related_name='card_games',
)
}}}
the signal is received correctly.
--
Ticket URL: <https://code.djangoproject.com/ticket/32515>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.df030850b3c6e1d8bc3236b2faf88a23%40djangoproject.com.