Opened 11 years ago

Closed 11 years ago

#20878 closed Uncategorized (invalid)

Use of datetime.date throws a 'naive datetime' warning

Reported by: joel@… Owned by: nobody
Component: Uncategorized Version: 1.4
Severity: Normal Keywords: timezone
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Use of datetime.date to represent a date (not a datetime) throws the same 'naive datetime' warning that using datetime.datetime does. This does not make sense, as a date object has no tzinfo attribute and no concept of time (and hence time zone).

Change History (1)

comment:1 by Aymeric Augustin, 11 years ago

Resolution: invalid
Status: newclosed

a date object has no tzinfo attribute and no concept of time (and hence time zone).

... and that's the very reason why dates objects aren't a well defined input for DateTimeField when USE_TZ = True. Hence the warning.

Use the appropriate data type for each field type:

  • DateField => datetime.date
  • DateTimeField => aware datetime.datetime
Note: See TracTickets for help on using tickets.
Back to Top