Skip to content Skip to sidebar Skip to footer

Many To Many Field Not Shown In Object While Using Signals To Detect Save Operation In Django

This is a follow up question to : Cant get post_save to work in Django My models are : class Car(models.Model): name = models.CharField(max_length=50) ... some other a

Solution 1:

post_save does not work on m2m fields. You have to use the m2m_changed signal.

Something like this:

defmy_m2m_signal(sender, **kwargs):
    action = kwargs.get('action')
    if action == 'post_add':
        print'post_add is activated on m2m'

signals.m2m_changed.connect(my_m2m_signal, sender=Person.car.through)

Post a Comment for "Many To Many Field Not Shown In Object While Using Signals To Detect Save Operation In Django"