2๐
โ
I feel silly for not figuring this out before. Instead of m2m_changed signal use the post_save
and post_delete
on the through model and it should essentially do the same thing. Then in my serializer just remove the instance.save()
if I am not doing other changes.
@receiver((post_save, post_delete), sender="main.OrderItem")
def update_order_when_items_changed(sender, instance, **kwargs):
instance.order.set_weight()
instance.order.set_total_price()
instance.order.save()
๐คJared Mackey
Source:stackexchange.com