1

Why doesn't Django in SQL table django_admin_log use TIMESTAMP instead of DATETIME for attribute action_time? I mean according to this answer it should be using TIMESTAMP.

Community
  • 1
  • 1
Jernej Jerin
  • 3,179
  • 9
  • 37
  • 53

1 Answers1

0

LogEntry's action_time field is a models.DateTimeField, which (perhaps unsurprisingly) is stored as a DATETIME field.

I think you've misunderstood the answer you linked - it recommends using DATETIME, not TIMESTAMP:

If you meant that you want to decide between using a UNIX timestamp or a native MySQL datetime field, go with the native format. You can do calculations within MySQL that way ("SELECT DATE_ADD(my_datetime, INTERVAL 1 DAY)") and it is simple to change the format of the value to a UNIX timestamp ("SELECT UNIX_TIMESTAMP(my_datetime)") when you query the record if you want to operate on it with PHP.

Community
  • 1
  • 1
Dominic Rodger
  • 97,747
  • 36
  • 197
  • 212
  • Yeah that is true. But the first part of that answer clearly says this: `Timestamps in MySQL generally used to track changes to records, and are often updated every time the record is changed` – Jernej Jerin Aug 01 '13 at 09:16
  • I think the first word "Timestamp" there is referring to the concept of a time value, not the MySQL field type (note that it's not capitalised). – Dominic Rodger Aug 01 '13 at 10:02