Opened 9 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 Changed 9 years ago by
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 Changed 9 years ago by
comment:3 Changed 9 years ago by
DatabaseOperations.convert_datetimefield_value
seems to be a better match for what I'm trying to achieve.
comment:4 Changed 9 years ago by
Owner: | changed from nobody to Aymeric Augustin |
---|---|
Status: | new → assigned |
comment:5 Changed 9 years ago by
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 Changed 9 years ago by
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
.