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)
该m2m_changed
信号永远不会被触发,因此该m2m_changed_labs
函数永远不会被调用。我希望m2m_changed_labs
每次将学校添加到实验室或从实验室中删除时调用该函数。