The configuration for each database backend should accept a `TIME_ZONE`
option to enforce interpretation of datetimes stored in that database as
naive values in that time zone.
Setting this option when `USE_TZ = False` could either be an error or
perform a conversion to the global default `TIME_ZONE`. The latter may be
too complicated to be worth the effort.
--
Ticket URL: <https://code.djangoproject.com/ticket/23820>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:1>
Comment (by aaugustin):
At least for SQLite, this will require getting rid of the
[https://docs.python.org/3/library/sqlite3.html#sqlite3.register_converter
global converters] as there is no way to register converters per
connection.
I'll try to replace the converters, which are quite messy anyway, with an
implementation of `DateTimeField.from_db_value`.
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:2>
Comment (by aaugustin):
`DatabaseOperations.convert_datetimefield_value` seems to be a better
match for what I'm trying to achieve.
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:3>
* status: new => assigned
* owner: nobody => aaugustin
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:4>
Comment (by aaugustin):
This will required getting rid of the global converters and adapters for
datetimes, because they're hardcoded to use UTC regardless of the database
connection being used.
Proposal: https://groups.google.com/d/msg/django-
developers/Ci_cs0KTagM/DchJIB8-vRsJ
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:5>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/4601
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:6>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"ed83881e648771d22658f21b939f66e75c499864" ed83881]:
{{{
#!CommitTicketReference repository=""
revision="ed83881e648771d22658f21b939f66e75c499864"
Fixed #23820 -- Supported per-database time zone.
The primary use case is to interact with a third-party database (not
primarily managed by Django) that doesn't support time zones and where
datetimes are stored in local time when USE_TZ is True.
Configuring a PostgreSQL database with the TIME_ZONE option while USE_TZ
is False used to result in silent data corruption. Now this is an error.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:10>
Comment (by Aymeric Augustin <aymeric.augustin@…>):
In [changeset:"ec186572e6cfde4cd4bc1491ff552c5d32211d9f" ec18657]:
{{{
#!CommitTicketReference repository=""
revision="ec186572e6cfde4cd4bc1491ff552c5d32211d9f"
Removed global timezone-aware datetime converters.
Refs #23820.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:8>
Comment (by Aymeric Augustin <aymeric.augustin@…>):
In [changeset:"d9521f66b1851b0eacd55bc78f801dc64123e333" d9521f6]:
{{{
#!CommitTicketReference repository=""
revision="d9521f66b1851b0eacd55bc78f801dc64123e333"
Removed global timezone-aware datetime adapters.
Refs #23820.
Fixed #19738.
Refs #17755. In order not to introduce a regression for raw queries,
parameters are passed through the connection.ops.value_to_db_* methods,
depending on their type.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23820#comment:9>