If I define auto_now = True
on a DateTimeField, than this field will be updated on every save(). But, how to update this field when something special happened?
For example: update DateTimeField only if some other field of the same Model has changed its state. Of course, I can define a trigger on a DB level, or catch pre_save or post_save signals to make stuff. But is there a way to do it another manner?
You can install
django-models-utils
and use it'sMonitorField
. It's a DateTimeField subclass that monitors another field on the model, and updates itself to the current date-time whenever the monitored field changes.