From a26a77b50861c8a348ec81c91481e22e556ede5d Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Mon, 5 Dec 2022 14:37:55 +0100 Subject: [PATCH] Future-proof for django 4.0 Minor changes to make the code compatible with django 4.0 Note that we can't actually upgrade to django 4.0 because that requires python 3.8, and www.eleves only has python 3.7, so we need to upgrade www.eleves first. --- WikiENS/settings/common.py | 5 ++++- WikiENS/urls.py | 19 +++++++++---------- wiki_groups/__init__.py | 1 - 3 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 wiki_groups/__init__.py diff --git a/WikiENS/settings/common.py b/WikiENS/settings/common.py index 5e78470..840f5e1 100644 --- a/WikiENS/settings/common.py +++ b/WikiENS/settings/common.py @@ -7,9 +7,12 @@ from django.contrib.messages import constants as messages try: from . import secret except ImportError: + import pathlib + dir_path = pathlib.Path(__file__).parent.resolve().as_posix() raise ImportError( "The secret.py file is missing.\n" - "For a development environment, simply copy secret_example.py" + "For a development environment, simply copy secret_example.py:\n" + f" $ cp {dir_path}/{{secret_example,secret}}.py" ) diff --git a/WikiENS/urls.py b/WikiENS/urls.py index ceafd69..2ff4476 100644 --- a/WikiENS/urls.py +++ b/WikiENS/urls.py @@ -1,23 +1,22 @@ -from django.conf.urls import url, include +from django.conf.urls import include +from django.urls import re_path from django.contrib import admin from allauth_ens.views import capture_login, capture_logout -from wiki.urls import get_pattern as get_wiki_pattern -from django_nyt.urls import get_pattern as get_nyt_pattern allauth_urls = [ # Catch login/logout views of admin site. - url(r'^_admin/login/$', capture_login), - url(r'^_admin/logout/$', capture_logout), + re_path(r'^_admin/login/$', capture_login), + re_path(r'^_admin/logout/$', capture_logout), # Allauth urls. - url(r'^_profil/', include('allauth.urls')), + re_path(r'^_profil/', include('allauth.urls')), ] urlpatterns = allauth_urls + [ - url(r'^_admin/', admin.site.urls), - url(r'^notifications/', get_nyt_pattern()), - url(r'^_groups/', include("wiki_groups.urls")), - url(r'', get_wiki_pattern()), + re_path(r'^_admin/', admin.site.urls), + re_path(r'^notifications/', include('django_nyt.urls')), + re_path(r'^_groups/', include("wiki_groups.urls")), + re_path(r'', include('wiki.urls')), ] # TODO add MEDIA_ROOT diff --git a/wiki_groups/__init__.py b/wiki_groups/__init__.py deleted file mode 100644 index 8588003..0000000 --- a/wiki_groups/__init__.py +++ /dev/null @@ -1 +0,0 @@ -default_app_config = "wiki_groups.apps.WikiGroupsConfig"