python - ManyToManyField aren't available in the post_save signal -
i need manipulate data django model after saving, need access manytomanyfield.
here's want do:
class lab(model): institute = manytomanyfield(institute) def post_save_lab(sender, instance, created, *args, **kwargs): if not instance.institute.all(): # data processing... post_save.connect(post_save_lab, sender=lab) the problem is, instance.institute.all() empty @ moment... how can know if lab has or has not institute?
i specify signal m2m_changed doesn't solve problem because data processing must done if there no elements in manytomany relation. therefor m2m_changed not called.
thanks!
the m2m cannot saved until model instance saved. if looking m2m instances when object created created==true in post save signal empty.
i think can have handler m2m_changed signal.
Comments
Post a Comment