Friday, June 28, 2013

Re: how to properly use the m2m_changed signal?

I have tried as well using the post_save signal and overriding the save() method. But in none of those cases Project.departments is populated yet when reaching my code :-/

On 06/28/2013 11:50 AM, Roberto López López wrote:


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',

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

Any help please? Thanks.



You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

--   Kind regards,    Roberto López López      System Developer  Parallab, Uni Computing  Høyteknologisenteret, Thormøhlensgate 55  N-5008 Bergen, Norway  Tel:        (+47) 555 84091

No comments:

Post a Comment