summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2019-07-20 15:38:43 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-12-04 18:22:08 +0100
commitc06492dd87342b5102db44f0d50fa0bb01cbb743 (patch)
tree25c8ba9910ed0851b4efd6bb81fb298adef420a2 /django/db/backends/postgresql
parentad88524e4db91dc2f148cf40184a81a454ee7aac (diff)
Fixed #23524 -- Allowed DATABASES['TIME_ZONE'] option on PostgreSQL.
Diffstat (limited to 'django/db/backends/postgresql')
-rw-r--r--django/db/backends/postgresql/base.py6
-rw-r--r--django/db/backends/postgresql/utils.py7
2 files changed, 4 insertions, 9 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index bf15a13018..0ab81ced74 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -47,7 +47,6 @@ from .features import DatabaseFeatures # NOQA isort:skip
from .introspection import DatabaseIntrospection # NOQA isort:skip
from .operations import DatabaseOperations # NOQA isort:skip
from .schema import DatabaseSchemaEditor # NOQA isort:skip
-from .utils import utc_tzinfo_factory # NOQA isort:skip
psycopg2.extensions.register_adapter(SafeString, psycopg2.extensions.QuotedString)
psycopg2.extras.register_uuid()
@@ -231,9 +230,12 @@ class DatabaseWrapper(BaseDatabaseWrapper):
cursor = self.connection.cursor(name, scrollable=False, withhold=self.connection.autocommit)
else:
cursor = self.connection.cursor()
- cursor.tzinfo_factory = utc_tzinfo_factory if settings.USE_TZ else None
+ cursor.tzinfo_factory = self.tzinfo_factory if settings.USE_TZ else None
return cursor
+ def tzinfo_factory(self, offset):
+ return self.timezone
+
@async_unsafe
def chunked_cursor(self):
self._named_cursor_idx += 1
diff --git a/django/db/backends/postgresql/utils.py b/django/db/backends/postgresql/utils.py
deleted file mode 100644
index 2c03ab36cd..0000000000
--- a/django/db/backends/postgresql/utils.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from django.utils.timezone import utc
-
-
-def utc_tzinfo_factory(offset):
- if offset != 0:
- raise AssertionError("database connection isn't set to UTC")
- return utc