Skip to content

Commit

Permalink
Support Django 4.0 (#138)
Browse files Browse the repository at this point in the history
Thorbenl authored Jan 11, 2022
1 parent 51936d8 commit 617f5aa
Showing 6 changed files with 87 additions and 31 deletions.
52 changes: 46 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -12,12 +12,12 @@ jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "3.10"

- name: Install
run: |
@@ -30,7 +30,7 @@ jobs:
- name: isort
run: |
isort . --recursive --check-only --diff
isort . --check-only --diff
build:
runs-on: ubuntu-latest
@@ -57,14 +57,28 @@ jobs:
- "py36-django21"
- "py36-django22"
- "py36-django30"
- "py36-django32"

- "py37-django111"
- "py37-django20"
- "py37-django21"
- "py37-django22"
- "py37-django30"
- "py37-django32"

- "py38-django20"
- "py38-django21"
- "py38-django22"
- "py38-django30"
- "py38-django32"
- "py38-django40"

- "py39-django30"
- "py39-django32"
- "py39-django40"

- "py310-django32"
- "py310-django40"

include:
- python: "2.7"
@@ -101,6 +115,8 @@ jobs:
tox_env: "py36-django22"
- python: "3.6"
tox_env: "py36-django30"
- python: "3.6"
tox_env: "py36-django32"

- python: "3.7"
tox_env: "py37-django111"
@@ -112,16 +128,40 @@ jobs:
tox_env: "py37-django22"
- python: "3.7"
tox_env: "py37-django30"
- python: "3.7"
tox_env: "py37-django32"

- python: "3.8"
tox_env: "py38-django20"
- python: "3.8"
tox_env: "py38-django21"
- python: "3.8"
tox_env: "py38-django22"
- python: "3.8"
tox_env: "py38-django30"
- python: "3.8"
tox_env: "py38-django32"
- python: "3.8"
tox_env: "py38-django40"

- python: "3.9"
tox_env: "py39-django30"
- python: "3.9"
tox_env: "py39-django32"
- python: "3.9"
tox_env: "py39-django40"

- python: "3.10"
tox_env: "py310-django32"
- python: "3.10"
tox_env: "py310-django40"


steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

7 changes: 4 additions & 3 deletions example/app/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django import VERSION
from django.contrib.auth.models import User
from django.template.response import TemplateResponse
from django.test import TestCase

try:
from django.urls import reverse
except ImportError:
if VERSION < (2, 0, 0):
from django.core.urlresolvers import reverse
else:
from django.urls import reverse


class TopLevelAdminTestCase(TestCase):
13 changes: 9 additions & 4 deletions example/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from django.conf.urls import url
from django import VERSION
from django.contrib import admin

urlpatterns = [
url(r'^admin/', admin.site.urls),
]
urlpatterns = []

if VERSION > (2, 0, 0):
from django.urls import re_path
urlpatterns.append(re_path(r'^admin/', admin.site.urls))
else:
from django.conf.urls import url
urlpatterns.append(url(r'^admin/', admin.site.urls))
10 changes: 5 additions & 5 deletions nested_inline/admin.py
Original file line number Diff line number Diff line change
@@ -10,9 +10,9 @@
from django.http import Http404
from django.templatetags.static import static
from django.utils.decorators import method_decorator
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.html import escape
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_protect

csrf_protect_m = method_decorator(csrf_protect)
@@ -255,7 +255,7 @@ def add_view(self, request, form_url='', extra_context=None):
media += extra_media

context = {
'title': _('Add %s') % force_text(opts.verbose_name),
'title': _('Add %s') % force_str(opts.verbose_name),
'adminform': adminForm,
'is_popup': "_popup" in request.GET,
'show_delete': False,
@@ -282,7 +282,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None):

if obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {
'name': force_text(opts.verbose_name), 'key': escape(object_id)})
'name': force_str(opts.verbose_name), 'key': escape(object_id)})

if request.method == 'POST' and "_saveasnew" in request.POST:
return self.add_view(request, form_url=reverse('admin:%s_%s_add' %
@@ -359,7 +359,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None):
media += extra_media

context = {
'title': _('Change %s') % force_text(opts.verbose_name),
'title': _('Change %s') % force_str(opts.verbose_name),
'adminform': adminForm,
'object_id': object_id,
'original': obj,
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Software Development :: Libraries :: Python Modules'
],
)
34 changes: 21 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -6,19 +6,27 @@ envlist =
{py27,py35,py36,py37}-django111,
{py35,py36,py37}-django20,
{py35,py36,py37}-django21,
{py35,py36,py37}-django22,
{py36,py37,py38}-django30,
{py36,py37,py38,py39}-django22,
{py35,py36,py37,py38,py39}-django30,
{py35,py36,py37,py38,py39,py310}-django32,
{py38,py39,py310}-{django40},

[testenv]
commands =
python manage.py test

commands = python manage.py test
envdir = {toxworkdir}/venvs/{envname}
setenv =
PYTHONDONTWRITEBYTECODE=1
PYTHONWARNINGS=once
deps =
django18: django==1.8.*
django19: django==1.9.*
django110: django==1.10.*
django111: django==1.11.*
django20: django==2.0.*
django21: django==2.1.*
django22: django==2.2.*
django30: django>=3.0a1,<3.1
django18: django==1.8.*
django19: django==1.9.*
django110: django==1.10.*
django111: django==1.11.*
django20: django==2.0.*
django21: django==2.1.*
django22: Django>=2.2,<3.0
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
django32: Django>=3.2,<4.0
django40: Django>=4.0,<5.0

0 comments on commit 617f5aa

Please sign in to comment.