[Django] #29861: Using timezone.now() instead of datetime.now() on class TimeField

1 view
Skip to first unread message

Django

unread,
Oct 17, 2018, 11:49:59 AM10/17/18
to django-...@googlegroups.com
#29861: Using timezone.now() instead of datetime.now() on class TimeField
-------------------------------------+-------------------------------------
Reporter: italomg | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: 2.1
layer (models, ORM) | Keywords: timezone;
Severity: Normal | TimeField; DateTimeField
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/29861>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 17, 2018, 12:03:41 PM10/17/18
to django-...@googlegroups.com
#29861: Use timezone.now() instead of datetime.now() for TimeField's
auto_now/auto_now_add

-------------------------------------+-------------------------------------
Reporter: italomg | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: timezone; | Triage Stage:
TimeField; DateTimeField | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => invalid


Comment:

Unlike `DateTimeField`, `TimeField` isn't timezone-aware. See #18691 for
discussion.

--
Ticket URL: <https://code.djangoproject.com/ticket/29861#comment:1>

Reply all
Reply to author
Forward
0 new messages