#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 , 6 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Summary: | Using timezone.now() instead of datetime.now() on class TimeField → Use timezone.now() instead of datetime.now() for TimeField's auto_now/auto_now_add |
Note:
See TracTickets
for help on using tickets.
Unlike
DateTimeField
,TimeField
isn't timezone-aware. See #18691, #27306, and a pull request thread where the change you suggested was proposed.