mirror of https://github.com/django/django.git
Refs #23524 -- Unified BaseDatabaseWrapper.timezone.
There was a special case in this property to return None when the database backend supports time zone. However, only the PostgreSQL backend supports time zones and it never uses this property.
This commit is contained in:
parent
a2e96f7969
commit
ad88524e4d
|
@ -117,18 +117,21 @@ class BaseDatabaseWrapper:
|
||||||
@cached_property
|
@cached_property
|
||||||
def timezone(self):
|
def timezone(self):
|
||||||
"""
|
"""
|
||||||
Time zone for datetimes stored as naive values in the database.
|
Return a tzinfo of the database connection time zone.
|
||||||
|
|
||||||
Return a tzinfo object or None.
|
This is only used when time zone support is enabled. When a datetime is
|
||||||
|
read from the database, it is always returned in this time zone.
|
||||||
|
|
||||||
This is only needed when time zone support is enabled and the database
|
When the database backend supports time zones, it doesn't matter which
|
||||||
doesn't support time zones. (When the database supports time zones,
|
time zone Django uses, as long as aware datetimes are used everywhere.
|
||||||
the adapter handles aware datetimes so Django doesn't need to.)
|
For simplicity, Django selects UTC.
|
||||||
|
|
||||||
|
When the database backend doesn't support time zones, the time zone
|
||||||
|
Django uses can be selected with the TIME_ZONE configuration option, so
|
||||||
|
it can match what other users of the database expect.
|
||||||
"""
|
"""
|
||||||
if not settings.USE_TZ:
|
if not settings.USE_TZ:
|
||||||
return None
|
return None
|
||||||
elif self.features.supports_timezones:
|
|
||||||
return None
|
|
||||||
elif self.settings_dict['TIME_ZONE'] is None:
|
elif self.settings_dict['TIME_ZONE'] is None:
|
||||||
return timezone.utc
|
return timezone.utc
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -297,6 +297,11 @@ backends.
|
||||||
* ``DatabaseOperations.fetch_returned_insert_columns()`` now requires an
|
* ``DatabaseOperations.fetch_returned_insert_columns()`` now requires an
|
||||||
additional ``returning_params`` argument.
|
additional ``returning_params`` argument.
|
||||||
|
|
||||||
|
* ``connection.timezone`` property is now ``'UTC'`` by default, or the
|
||||||
|
:setting:`TIME_ZONE <DATABASE-TIME_ZONE>` when :setting:`USE_TZ` is ``True``
|
||||||
|
on databases that support time zones. Previously, it was ``None`` on
|
||||||
|
databases that support time zones.
|
||||||
|
|
||||||
Dropped support for MariaDB 10.1
|
Dropped support for MariaDB 10.1
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue