Skip to content

Commit cc317f3

Browse files
authored
Django 4.0 compatible (#498)
* Fix for Django 4.0 * Replace some unnecessary re_path with path
1 parent 0be59a7 commit cc317f3

9 files changed

Lines changed: 24 additions & 22 deletions

File tree

coderedcms/admin_urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.urls import include, path, re_path
1+
from django.urls import include, path
22
from wagtail.admin import urls as wagtailadmin_urls
33
from coderedcms.views import import_index, import_pages_from_csv_file
44

@@ -8,5 +8,5 @@
88
import_index, name="import_index"),
99
path('codered/import-export/import_from_csv/',
1010
import_pages_from_csv_file, name="import_from_csv"),
11-
re_path(r'', include(wagtailadmin_urls)),
11+
path('', include(wagtailadmin_urls)),
1212
]

coderedcms/importexport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from django.apps import apps
1515
from django.contrib.contenttypes.models import ContentType
1616
from django.db import models, transaction
17-
from django.utils.translation import ugettext as _
17+
from django.utils.translation import gettext as _
1818
from modelcluster.models import get_all_child_relations
1919
from wagtail.admin.widgets import AdminPageChooser
2020
from wagtail.core.models import Page

coderedcms/project_template/basic/project_name/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.conf import settings
2-
from django.urls import include, path, re_path
2+
from django.urls import include, path
33
from django.contrib import admin
44
from wagtail.documents import urls as wagtaildocs_urls
55
from coderedcms import admin_urls as coderedadmin_urls
@@ -20,11 +20,11 @@
2020
# For anything not caught by a more specific rule above, hand over to
2121
# the page serving mechanism. This should be the last pattern in
2222
# the list:
23-
re_path(r'', include(codered_urls)),
23+
path('', include(codered_urls)),
2424

2525
# Alternatively, if you want CMS pages to be served from a subpath
2626
# of your site, rather than the site root:
27-
# re_path(r"^pages/", include(codered_urls)),
27+
# path("pages/", include(codered_urls)),
2828
]
2929

3030

coderedcms/project_template/sass/project_name/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.conf import settings
2-
from django.urls import include, path, re_path
2+
from django.urls import include, path
33
from django.contrib import admin
44
from wagtail.documents import urls as wagtaildocs_urls
55
from coderedcms import admin_urls as coderedadmin_urls
@@ -20,11 +20,11 @@
2020
# For anything not caught by a more specific rule above, hand over to
2121
# the page serving mechanism. This should be the last pattern in
2222
# the list:
23-
re_path(r'', include(codered_urls)),
23+
path('', include(codered_urls)),
2424

2525
# Alternatively, if you want CMS pages to be served from a subpath
2626
# of your site, rather than the site root:
27-
# re_path(r'^pages/', include(codered_urls)),
27+
# path("pages/", include(codered_urls)),
2828
]
2929

3030

coderedcms/search_urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from django.urls import re_path
1+
from django.urls import path
22
from coderedcms.views import search
33

44
urlpatterns = [
5-
re_path(r'', search, name='codered_search'),
5+
path('', search, name='codered_search'),
66
]

coderedcms/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
urlpatterns = [
1717
# CodeRed custom URLs
18-
re_path(r'^favicon\.ico$', favicon, name='codered_favicon'),
19-
re_path(r'^robots\.txt$', robots, name='codered_robots'),
20-
re_path(r'^sitemap\.xml$', sitemap, name='codered_sitemap'),
18+
path(r'favicon.ico', favicon, name='codered_favicon'),
19+
path(r'robots.txt', robots, name='codered_robots'),
20+
path(r'sitemap.xml', sitemap, name='codered_sitemap'),
2121
re_path(r'^{0}(?P<path>.*)$'.format(
2222
crx_settings.CRX_PROTECTED_MEDIA_URL.lstrip('/')),
2323
serve_protected_file,
@@ -34,5 +34,5 @@
3434
path('ajax/calendar/events/', event_get_calendar_events, name='event_get_calendar_events'),
3535

3636
# Wagtail
37-
re_path(r'', include(wagtailcore_urls)),
37+
path('', include(wagtailcore_urls)),
3838
]

coderedcms/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.core.paginator import Paginator, InvalidPage, EmptyPage, PageNotAnInteger
99
from django.shortcuts import redirect, render
1010
from django.utils import timezone
11-
from django.utils.translation import ungettext, gettext_lazy as _
11+
from django.utils.translation import ngettext, gettext_lazy as _
1212
from icalendar import Calendar
1313
from wagtail.admin import messages
1414
from wagtail.search.backends import db, get_search_backend
@@ -261,7 +261,7 @@ def import_pages_from_csv_file(request):
261261
"Import failed: %(reason)s") % {'reason': e}
262262
)
263263
else:
264-
messages.success(request, ungettext(
264+
messages.success(request, ngettext(
265265
"%(count)s page imported.",
266266
"%(count)s pages imported.",
267267
page_count) % {'count': page_count}

coderedcms/wagtail_flexible_forms/wagtail_hooks.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from django.conf.urls import url
21
from django.contrib.admin import SimpleListFilter
32
from django.contrib.admin.utils import quote
43
from django.shortcuts import redirect
5-
from django.urls import reverse
4+
from django.urls import path, reverse
65
from django.utils.translation import gettext_lazy as _
76
from wagtail.contrib.modeladmin.helpers import (
87
PermissionHelper, PagePermissionHelper, PageAdminURLHelper, AdminURLHelper,
@@ -302,9 +301,11 @@ def set_status_view(self, request, instance_pk):
302301
def get_admin_urls_for_registration(self):
303302
urls = super().get_admin_urls_for_registration()
304303
urls += (
305-
url(self.url_helper.get_action_url_pattern('set_status'),
304+
path(
305+
self.url_helper.get_action_url_pattern('set_status'),
306306
self.set_status_view,
307-
name=self.url_helper.get_action_url_name('set_status')),
307+
name=self.url_helper.get_action_url_name('set_status')
308+
),
308309
)
309310
return urls
310311

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'Programming Language :: Python :: 3 :: Only',
3535
'Framework :: Django',
3636
'Framework :: Django :: 3.2',
37+
'Framework :: Django :: 4.0',
3738
'Framework :: Wagtail',
3839
'Framework :: Wagtail :: 2',
3940
'Topic :: Internet :: WWW/HTTP',
@@ -45,7 +46,7 @@
4546
'beautifulsoup4>=4.8,<4.10', # should be the same as wagtail
4647
'django-eventtools==1.0.*',
4748
'django-bootstrap4==22.1',
48-
'Django>=3.2,<4.0', # should be the same as wagtail
49+
'Django>=3.2,<4.1', # should be the same as wagtail
4950
'geocoder==1.38.*',
5051
'icalendar==4.0.*',
5152
'wagtail==2.16.*',

0 commit comments

Comments
 (0)