Opened 10 years ago
Closed 9 years ago
#23820 closed New feature (fixed)
Make it possible to override USE_TZ & TIME_ZONE on a per-database basis
Reported by: | Aymeric Augustin | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When integrating with a legacy database, datetimes are most often encoded in local time. This doesn't work well with projects where USE_TZ = True
.
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.
Change History (10)
comment:1 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 10 years ago
comment:3 by , 10 years ago
DatabaseOperations.convert_datetimefield_value
seems to be a better match for what I'm trying to achieve.
comment:4 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 10 years ago
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
comment:7 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
At least for SQLite, this will require getting rid of the 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
.