1👍
Setting auto_now/auto_now_add fields happens in the application, not in the database (in DateTimeField.pre_save
).
You might have some really weird race condition, but the easiest explanation is probably that the clocks on your web servers are not in sync.
0👍
You are defining both auto_now
and auto_now_add
in updated_at
datetime field which is wrong.
As per Django docs on DateTime field:
The options auto_now_add, auto_now, and default are mutually
exclusive. Any combination of these options will result in an error.
It should be something like:
updated_at = models.DateTimeField(auto_now=True, blank=False, null=True, default=None)
created_at = models.DateTimeField(auto_now_add=True, blank=True, null=True)
Note:
auto_now
: Use this option for setting ‘last_modified’ timestamps
auto_now_add:
Use this option for setting the ‘creation’ timestamp.
- Django admin – add more controls to the field
- Django mutliple same GET parameter names not working
- Youtube not able to play on my django-heroku app. Giving me a mixed content error message
Source:stackexchange.com