On a slightly different note, you definitely do not want this:
created_on = models.DateTimeField(…, default=datetime.datetime.utcnow())
This actually calls utcnow()
when your models.py
file is loaded (which will happen when you manage.py runserver
) and use that single point in time for the default value for every instance there-after. What you want is this:
created_on = models.DateTimeField(…, default=datetime.datetime.utcnow)
The default
argument can accept a callable, which will be called each time the default value is needed for a new instance. Have a look at the documentation.