Friday, June 28, 2013

how to properly use the m2m_changed signal?


Hi,

I am trying to listen to the m2m_changed signal on my models, but I can't make it work. Even the execution flow does not reach the linked method!
class Project(models.Model):
    departments = models.ManyToManyField('department.Department', related_name='projects',
                                         through='project.ProjectDepartmentMembership')

@receiver(m2m_changed, sender=Project.departments.through)
def _on_change_m2m(sender, instance, action, reverse, model, pk_set, using, **kwargs):
    pass
As interface I am using the django admin, and departments appears as an inline of Project

Any help please? Thanks.

Cheers,

Roberto


No comments:

Post a Comment