Opened 4 years ago

Closed 4 years ago

Last modified 4 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 Changed 4 years ago by Tim Graham

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 4 years ago by Tim Graham (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top