I have a MySQL database, right now I\'m generating all of the datetime fields as models.DateTimeField. Is there a way to get a timestamp instead? I
To automatically update on insert and update use this:
created = DateTimeField(auto_now_add=True, editable=False, null=False, blank=False)
last_modified = DateTimeField(auto_now=True, editable=False, null=False, blank=False)
The DateTimeField should store UTC (check your DB settings, I know from Postgres that there it is the case). You can use l10n in the templates and format via:
{{ object.created|date:'SHORT_DATETIME_FORMAT' }}
Seconds since Unix Epoch:
{{ object.created|date:'U' }}
See https://docs.djangoproject.com/en/1.10/ref/templates/builtins/#date