[PATCH 3/6] requirements: Bump Django to 3.2.x, django-filter to 21.1

Stephen Finucane stephen at that.guru
Thu Sep 30 20:55:15 AEST 2021


It seems the ORM is now smarter and requires less JOINs that previously
in two tests. In addition, a new setting is required to ensure the type
of our primary field columns doesn't change when Django 4.0 is released.

We drop support for Django 3.1 in the process, though this doesn't have
much of a real-world impact since we still support Django 2.2, an LTS
release.

Signed-off-by: Stephen Finucane <stephen at that.guru>
---
 patchwork/settings/base.py                           |  4 ++++
 patchwork/tests/api/test_event.py                    |  6 +++++-
 patchwork/tests/api/test_patch.py                    |  6 +++++-
 .../notes/django-3-2-support-363b32e74bdcf017.yaml   |  9 +++++++++
 requirements-dev.txt                                 |  4 ++--
 requirements-prod.txt                                |  4 ++--
 tox.ini                                              | 12 ++++++------
 7 files changed, 33 insertions(+), 12 deletions(-)
 create mode 100644 releasenotes/notes/django-3-2-support-363b32e74bdcf017.yaml

diff --git patchwork/settings/base.py patchwork/settings/base.py
index c1bb9b27..ff14d91b 100644
--- patchwork/settings/base.py
+++ patchwork/settings/base.py
@@ -68,6 +68,10 @@ TEMPLATES = [
     },
 ]
 
+# TODO(stephenfin): Consider changing to BigAutoField when we drop support for
+# Django < 3.2
+DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
+
 DEFAULT_FROM_EMAIL = 'Patchwork <patchwork at patchwork.example.com>'
 
 SERVER_EMAIL = DEFAULT_FROM_EMAIL
diff --git patchwork/tests/api/test_event.py patchwork/tests/api/test_event.py
index 32e99366..62506a5b 100644
--- patchwork/tests/api/test_event.py
+++ patchwork/tests/api/test_event.py
@@ -5,6 +5,7 @@
 
 import unittest
 
+import django
 from django.conf import settings
 from django.urls import reverse
 
@@ -187,7 +188,10 @@ class TestEventAPI(utils.APITestCase):
         for _ in range(3):
             self._create_events()
 
-        with self.assertNumQueries(28):
+        # TODO(stephenfin): Remove when we drop support for Django < 3.2
+        num_queries = 28 if django.VERSION < (3, 2) else 27
+
+        with self.assertNumQueries(num_queries):
             self.client.get(self.api_url())
 
     def test_order_by_date_default(self):
diff --git patchwork/tests/api/test_patch.py patchwork/tests/api/test_patch.py
index 1c616409..36c3e5f9 100644
--- patchwork/tests/api/test_patch.py
+++ patchwork/tests/api/test_patch.py
@@ -7,6 +7,7 @@ import email.parser
 from email.utils import make_msgid
 import unittest
 
+import django
 from django.conf import settings
 from django.urls import NoReverseMatch
 from django.urls import reverse
@@ -228,7 +229,10 @@ class TestPatchAPI(utils.APITestCase):
         series = create_series()
         create_patches(5, series=series)
 
-        with self.assertNumQueries(7):
+        # TODO(stephenfin): Remove when we drop support for Django < 3.2
+        num_queries = 7 if django.VERSION < (3, 2) else 5
+
+        with self.assertNumQueries(num_queries):
             self.client.get(self.api_url())
 
     @utils.store_samples('patch-detail')
diff --git releasenotes/notes/django-3-2-support-363b32e74bdcf017.yaml releasenotes/notes/django-3-2-support-363b32e74bdcf017.yaml
new file mode 100644
index 00000000..039535e9
--- /dev/null
+++ releasenotes/notes/django-3-2-support-363b32e74bdcf017.yaml
@@ -0,0 +1,9 @@
+---
+features:
+  - |
+    `Django 3.2 <https://docs.djangoproject.com/en/dev/releases/3.2/>`_ is now
+    supported.
+upgrade:
+  - |
+    Django 3.1 is no longer supported. It is no longer supported upstream and
+    most distributions provide a newer version.
diff --git requirements-dev.txt requirements-dev.txt
index d58dfaa9..437b1e8b 100644
--- requirements-dev.txt
+++ requirements-dev.txt
@@ -1,6 +1,6 @@
-Django~=3.1.0
+Django~=3.2.0
 djangorestframework~=3.12.0
-django-filter~=2.4.0
+django-filter~=21.1.0
 django-debug-toolbar~=3.2.0
 django-dbbackup~=3.3.0
 -r requirements-test.txt
diff --git requirements-prod.txt requirements-prod.txt
index 6bac4d6a..fa6bc95f 100644
--- requirements-prod.txt
+++ requirements-prod.txt
@@ -1,5 +1,5 @@
-Django~=3.1.0
+Django~=3.2.0
 djangorestframework~=3.12.0
-django-filter~=2.4.0
+django-filter~=21.1.0
 psycopg2-binary~=2.8.0
 sqlparse~=0.4.0
diff --git tox.ini tox.ini
index 46d72517..8eab01da 100644
--- tox.ini
+++ tox.ini
@@ -1,6 +1,6 @@
 [tox]
 minversion = 3.2
-envlist = pep8,docs,py{36,37,38,39}-django{22,30,31}
+envlist = pep8,docs,py{36,37,38,39}-django{22,31,32}
 skipsdist = true
 ignore_basepython_conflict = true
 
@@ -10,13 +10,13 @@ deps =
     -r{toxinidir}/requirements-test.txt
     django22: django>=2.2,<2.3
     django22: djangorestframework>=3.10,<3.13
-    django22: django-filter>=2.1,<3.0
-    django30: django>=3.0,<3.1
-    django30: djangorestframework>=3.10,<3.13
-    django30: django-filter>=2.2,<3.0
+    django22: django-filter~=21.1.0
     django31: django>=3.1,<3.2
     django31: djangorestframework>=3.10,<3.13
-    django31: django-filter>=2.3,<3.0
+    django31: django-filter~=21.1.0
+    django32: django>=3.2,<3.3
+    django32: djangorestframework>=3.10,<3.13
+    django32: django-filter~=21.1.0
 setenv =
     DJANGO_SETTINGS_MODULE = patchwork.settings.dev
     PYTHONDONTWRITEBYTECODE = 1
-- 
2.31.1



More information about the Patchwork mailing list