Imagine I have the two models Pizza
and Topping
and the Pizza
model has a last_changed
field with auto_now=True
and a ManyToMany
relationship to Topping
.
I now want the last_changed
field to be updated whenever I add another Topping
to the Pizza
. Unfortunately this is not updated automatically since the Pizza
model does not get saved in such a case. This is because the ManyToMany
relationship is held in a separate (auto created) model and table.
So what would be the best approach to update the last_changed
field?