[Solved]-Django signal m2m_changed not triggered

12👍

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

I wasted hours on it this week.

3👍

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

2👍

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)

0👍

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.

👤Thomas

Leave a comment