diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 8864a4f543..e49d453f94 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -36,8 +36,8 @@ def psycopg2_version(): PSYCOPG2_VERSION = psycopg2_version() -if PSYCOPG2_VERSION < (2, 5, 4): - raise ImproperlyConfigured("psycopg2_version 2.5.4 or newer is required; you have %s" % psycopg2.__version__) +if PSYCOPG2_VERSION < (2, 8, 4): + raise ImproperlyConfigured("psycopg2 version 2.8.4 or newer is required; you have %s" % psycopg2.__version__) # Some of these import psycopg2, so import them after checking if it's installed. diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index ab86599e40..2886206959 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -114,7 +114,7 @@ below for information on how to set up your database correctly. PostgreSQL notes ================ -Django supports PostgreSQL 10 and higher. `psycopg2`_ 2.5.4 or higher is +Django supports PostgreSQL 10 and higher. `psycopg2`_ 2.8.4 or higher is required, though the latest release is recommended. .. _psycopg2: https://www.psycopg.org/ diff --git a/docs/releases/4.0.txt b/docs/releases/4.0.txt index 937363f527..31e327eaf9 100644 --- a/docs/releases/4.0.txt +++ b/docs/releases/4.0.txt @@ -419,6 +419,9 @@ Dropped support for PostgreSQL 9.6 Upstream support for PostgreSQL 9.6 ends in November 2021. Django 4.0 supports PostgreSQL 10 and higher. +Also, the minimum supported version of ``psycopg2`` is increased from 2.5.4 to +2.8.4, as ``psycopg2`` 2.8.4 is the first release to support Python 3.8. + Dropped support for Oracle 12.2 and 18c --------------------------------------- diff --git a/tests/backends/postgresql/tests.py b/tests/backends/postgresql/tests.py index e8dfcf2f62..1905147f6f 100644 --- a/tests/backends/postgresql/tests.py +++ b/tests/backends/postgresql/tests.py @@ -207,9 +207,7 @@ class Tests(TestCase): The transaction level can be configured with DATABASES ['OPTIONS']['isolation_level']. """ - import psycopg2 from psycopg2.extensions import ( - ISOLATION_LEVEL_READ_COMMITTED as read_committed, ISOLATION_LEVEL_SERIALIZABLE as serializable, ) @@ -217,8 +215,7 @@ class Tests(TestCase): # and the isolation level isn't reported as 0. This test assumes that # PostgreSQL is configured with the default isolation level. # Check the level on the psycopg2 connection, not the Django wrapper. - default_level = read_committed if psycopg2.__version__ < '2.7' else None - self.assertEqual(connection.connection.isolation_level, default_level) + self.assertIsNone(connection.connection.isolation_level) new_connection = connection.copy() new_connection.settings_dict['OPTIONS']['isolation_level'] = serializable diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py index 62a495d5a7..ba04c15e24 100644 --- a/tests/postgres_tests/test_array.py +++ b/tests/postgres_tests/test_array.py @@ -36,7 +36,6 @@ try: from django.contrib.postgres.forms import ( SimpleArrayField, SplitArrayField, SplitArrayWidget, ) - from django.db.backends.postgresql.base import PSYCOPG2_VERSION except ImportError: pass @@ -193,8 +192,6 @@ class TestSaveLoad(PostgreSQLTestCase): self.assertEqual(field.base_field.model, IntegerArrayModel) def test_nested_nullable_base_field(self): - if PSYCOPG2_VERSION < (2, 7, 5): - self.skipTest('See https://github.com/psycopg/psycopg2/issues/325') instance = NullableIntegerArrayModel.objects.create( field_nested=[[None, None], [None, None]], ) diff --git a/tests/requirements/postgres.txt b/tests/requirements/postgres.txt index 59041b90ef..f0288c8b74 100644 --- a/tests/requirements/postgres.txt +++ b/tests/requirements/postgres.txt @@ -1 +1 @@ -psycopg2>=2.5.4 +psycopg2>=2.8.4