[Solved]-Django signal m2m_changed not triggered


This is an open bug: https://code.djangoproject.com/ticket/16073

I wasted hours on it this week.


You are connecting it twice, once with m2m_changed.connect and the other time with receiver decorator.


Not sure if it will help, but the following is working for me:

class Flow(models.Model):
    datalist = models.ManyToManyField(Data)

from django.db.models.signals import post_save, pre_delete, m2m_changed

def handle_flow(sender, instance, *args, **kwargs):
    logger.debug("Signal catched !")

m2m_changed.connect(handle_flow, sender=Flow.datalist.through)


I’m not sure if this will help, but are you sure that you should use Sender.pages.through for this special case? perhaps if you tried @reciever(m2m_changed, sender=PageChild)

Note: if you have @reciever, you do not need m2_changed.connect(…) as @reciever already performs the connect operation.


Leave a comment