Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29861 closed Cleanup/optimization (invalid)

Use timezone.now() instead of datetime.now() for TimeField's auto_now/auto_now_add

Reported by: Ítalo de Moraes Garcia Owned by: nobody
Component: Database layer (models, ORM) Version: 2.1
Severity: Normal Keywords: timezone; TimeField; DateTimeField
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

On jango db model Class DateTimeField when using arguments like auto_now* the time will be set on that field value using timezone.now().
While its sibling class TimeField' uses datetime.datetime.now() to set the value.

Maybe it makes more sense to just use timezone.now() in both places.

Change History (1)

comment:1 by Tim Graham, 6 years ago

Resolution: invalid
Status: newclosed
Summary: Using timezone.now() instead of datetime.now() on class TimeFieldUse timezone.now() instead of datetime.now() for TimeField's auto_now/auto_now_add

Unlike DateTimeField, TimeField isn't timezone-aware. See #18691, #27306, and a pull request thread where the change you suggested was proposed.

Last edited 6 years ago by Tim Graham (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top