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
|
||||
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
|
||||
doesn't support time zones. (When the database supports time zones,
|
||||
the adapter handles aware datetimes so Django doesn't need to.)
|
||||
When the database backend supports time zones, it doesn't matter which
|
||||
time zone Django uses, as long as aware datetimes are used everywhere.
|
||||
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:
|
||||
return None
|
||||
elif self.features.supports_timezones:
|
||||
return None
|
||||
elif self.settings_dict['TIME_ZONE'] is None:
|
||||
return timezone.utc
|
||||
else:
|
||||
|
|
|
@ -297,6 +297,11 @@ backends.
|
|||
* ``DatabaseOperations.fetch_returned_insert_columns()`` now requires an
|
||||
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
|
||||
--------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue