Repository: openwisp/django-x509 (language: python)

Issue:
[deps] Add support for django 3.2 and django 4.0 alpha
Let's make sure this module can run with Django 3.2 and Django 4.0 alpha.


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7132a45..931d8a5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -21,9 +21,13 @@ jobs:
           - 3.8
           - 3.9
         django-version:
-          - django~=2.2.0
           - django~=3.0.0
           - django~=3.1.0
+          - django~=3.2.0
+        include:
+          - django-version: django~=4.0a1
+            python-version: 3.8
+            experimental: true
 
     steps:
     - uses: actions/checkout@v2
diff --git a/django_x509/apps.py b/django_x509/apps.py
index 90c40d7..02085eb 100644
--- a/django_x509/apps.py
+++ b/django_x509/apps.py
@@ -1,7 +1,8 @@
 from django.apps import AppConfig
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
 
 
 class DjangoX509Config(AppConfig):
     name = 'django_x509'
     verbose_name = _('x509 Certificates')
+    default_auto_field = 'django.db.models.AutoField'
diff --git a/django_x509/base/admin.py b/django_x509/base/admin.py
index 23a3887..321cdd6 100644
--- a/django_x509/base/admin.py
+++ b/django_x509/base/admin.py
@@ -1,12 +1,11 @@
 from django import forms
-from django.conf.urls import url
 from django.contrib.admin import ModelAdmin
 from django.http import HttpResponse
 from django.shortcuts import get_object_or_404, render
-from django.urls import reverse
+from django.urls import path, reverse
 from django.utils.html import format_html
+from django.utils.translation import gettext_lazy as _
 from django.utils.translation import ngettext
-from django.utils.translation import ugettext_lazy as _
 
 from django_x509 import settings as app_settings
 
@@ -129,7 +128,7 @@ class Media:
 
     def get_urls(self):
         return [
-            url(r'^x509/ca/(?P<pk>[^/]+).crl$', self.crl_view, name='crl')
+            path('x509/ca/<int:pk>.crl', self.crl_view, name='crl')
         ] + super().get_urls()
 
     def crl_view(self, request, pk):
diff --git a/django_x509/base/models.py b/django_x509/base/models.py
index d14ccd5..780ac63 100644
--- a/django_x509/base/models.py
+++ b/django_x509/base/models.py
@@ -9,7 +9,7 @@
 from django.utils import timezone
 from django.utils.functional import cached_property
 from django.utils.safestring import mark_safe
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
 from jsonfield import JSONField
 from model_utils.fields import AutoCreatedField, AutoLastModifiedField
 from OpenSSL import crypto
diff --git a/requirements.txt b/requirements.txt
index d7ddc47..b67d8b8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,5 @@
-django>=2.2.0,<3.2.0
-openwisp-utils~=0.7.2
+django>=3.0.0,<=4.1.0
+openwisp-utils @ https://github.com/openwisp/openwisp-utils/tarball/master
 jsonfield>=3.1.0,<4.0.0
 cryptography~=3.4
 pyopenssl>=17.5.0,<20.1.0
-swapper~=1.1.0


Test patch:
diff --git a/tests/openwisp2/urls.py b/tests/openwisp2/urls.py
index 19fa3ed..25288ff 100644
--- a/tests/openwisp2/urls.py
+++ b/tests/openwisp2/urls.py
@@ -1,7 +1,7 @@
-from django.conf.urls import url
 from django.contrib import admin
 from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+from django.urls import path
 
-urlpatterns = [url(r'^admin/', admin.site.urls)]
+urlpatterns = [path('admin/', admin.site.urls)]
 
 urlpatterns += staticfiles_urlpatterns()