2👍
✅
Well, usage of default values for DateField
is clearly declared in the Django documentation. Django DateField Documentation
According to the docs, you can do the following:
inserted_time = models.DateTimeField(auto_now_add=True)
This will set current datetime
to this field. This value will be by default and will be set once you create an object. Warning: now, even if you set custom datetime to this field, it will be ignored!
It will not work if you create your object using plain SQL. Django should use its own ORM in order to set default values.
Source:stackexchange.com