File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 11
11
'default' : dj_database_url .config (default = 'postgres:///psqlextra' ),
12
12
}
13
13
14
- DATABASES ['default' ]['ENGINE' ] = 'psqlextra.backend '
14
+ DATABASES ['default' ]['ENGINE' ] = 'tests.psqlextra_test_backend '
15
15
16
16
LANGUAGE_CODE = 'en'
17
17
LANGUAGES = (
Original file line number Diff line number Diff line change
1
+ from datetime import timezone
2
+
3
+ import django
4
+
5
+ from django .conf import settings
6
+
7
+ from psqlextra .backend .base import DatabaseWrapper as PSQLExtraDatabaseWrapper
8
+
9
+
10
+ class DatabaseWrapper (PSQLExtraDatabaseWrapper ):
11
+ # Works around the compatibility issue of Django <3.0 and psycopg2.9
12
+ # in combination with USE_TZ
13
+ #
14
+ # See: https://github.com/psycopg/psycopg2/issues/1293#issuecomment-862835147
15
+ if django .VERSION < (3 , 1 ):
16
+
17
+ def create_cursor (self , name = None ):
18
+ cursor = super ().create_cursor (name )
19
+ cursor .tzinfo_factory = (
20
+ lambda offset : timezone .utc if settings .USE_TZ else None
21
+ )
22
+
23
+ return cursor
You can’t perform that action at this time.
0 commit comments