Have you tried sender=School.labs.through
?
and with your receiver method like this:
def m2m_changed_labs(sender, **kwargs): # notice sender instead of *args
print "signal received"
That's the sender used in the example from the docs.
سؤال
class Lab(Model):
pass
class School(Model):
labs = ManyToManyField(Lab, related_name='schools')
def m2m_changed_labs(*args, **kwargs):
pass
m2m_changed.connect(m2m_changed_labs, sender=Lab.schools)
The m2m_changed
signal is never triggered, therefore the m2m_changed_labs
function is never called. I want the m2m_changed_labs
function to be called each time a school is added to or removed from a lab.
المحلول
Have you tried sender=School.labs.through
?
and with your receiver method like this:
def m2m_changed_labs(sender, **kwargs): # notice sender instead of *args
print "signal received"
That's the sender used in the example from the docs.