I have a django model called Blog.
I’d like to add a field to my current model that is for last_modified_date. I know how to set a default value, but I would like somehow for it to get automatically updated anytime I modify the blog entry via the admin interface.
Is there some way to force this value to the current time on each admin site save?
Also would there be some way to add a mod_count field and have it automatically calculated on each modify of the admin site blog entry?
Create a
DateTimeFieldin your model. Have it update whenever it is saved. This requires you to use theauto_now_addoption:It should look something like this:
Model field reference
For the second part, I think you have to overload
As James Bennett describes here. It will look something like this: