I want to add creation and update timestamps to several models in my django app. And I wonder what way is the best practice?
I found that it can be done with auto_now
and auto_now_add
(or preferably via custom save()
method). I call this programmatic way.
Another way that comes to mind is defining a trigger function and assigning it to multiple database tables on the level of database (postgresql).
So what is the best practice of doing things like that? (This may include total price calculations and any other column info that is calculated using other column data). Triggers or code?
Note:
This might be an opinion-based question. If so, Let me know in the comment, I will delete the question after I hear one or two opinions of an experienced developer.