#29580: Now() database function doesn't respect TIME_ZONE with USE_TZ
-------------------------------------+-------------------------------------
Reporter: lobziik | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: postgres, | Triage Stage:
postgresql, time zones, USE_TZ | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by lobziik):
Replying to [comment:2 Tim Graham]:
> I don't see anything in
[https://docs.djangoproject.com/en/dev/ref/models/database-functions/#now
the documentation] for the `Now` database function that suggests that
`settings.TIME_ZONE` should be respected: "Returns the database server’s
current date and time when the query is executed".
>
> From the [https://docs.djangoproject.com/en/dev/topics/i18n/timezones/
time zone documentation], "When support for time zones is enabled, Django
stores datetime information in UTC in the database, uses time-zone-aware
datetime objects internally, and translates them to the end user’s time
zone in templates and forms."
Yep, seems title is so misleading. Can I change it and reopen ticket?
The main problem described is:
>Seems that PostgreSQL database wrapper doesn't set the timezone on
connection initialization.
And Now() behaviour is just a side effect.
And according to
[https://docs.djangoproject.com/en/2.0/topics/i18n/timezones/#postgresql
time zone documentation]: "As a consequence, if you’re using PostgreSQL,
you can switch between USE_TZ = False and USE_TZ = True freely. The
database connection’s time zone will be set to TIME_ZONE or UTC
respectively, so that Django obtains correct datetimes in all cases. You
don’t need to perform any data conversions."
--
Ticket URL: <https://code.djangoproject.com/ticket/29580#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.eaec3c9d28d91be6ff872a9e921271a0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.