I am trying to add a creation_time
attribute to my documents. The following would be an example:
import datetime
class MyModel(mongoengine.Docu
Traditionally, I've set the creation_date
default to datetime.now()
and then have hidden the field on the admin form so you remove the possibility of a user overwriting the correct value. That requires almost no code.
Overriding the save method as suggested by Willian is also effective since you can programmtically block any updates to the creation_date
and update the modfied_date
at the same time.