Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#19055 closed Uncategorized (needsinfo)

DateField uses date() which might not be correct in timezone aware situations

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


DateField uses date() to convert to date, which might not be correct in timezone aware situations. At least according to documentation, a more precise handling should be made.

Change History (4)

comment:1 Changed 4 years ago by Aymeric Augustin

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: needsinfo
Status: newclosed

This is probably on purpose and not changeable in a backwards compatible way. See

If you tell me which function you're referring to, I'll take a look.

comment:2 Changed 4 years ago by Mitar

I think about this lines:

Otherwise, such function used everywhere instead of .date() call would not really break backwards compatibility, I believe.

comment:3 Changed 4 years ago by Aymeric Augustin

My personal opinion is that DateField shouldn't accept datetime objects. However it did long before I started using Django :)

My advice is not to mix dates and datetimes.

Could you clarify why you need to feed a datetime into a DateField?

comment:4 Changed 3 years ago by Mitar

I think you get this when you specify default value with call?

Note: See TracTickets for help on using tickets.
Back to Top