From 0ca4c2399fc133ca7890a6ab05d5a4b7c399784b Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Sat, 22 Jan 2022 17:04:38 +0100 Subject: [PATCH] Fix url config for Django4 url() is no longer available, has to be replaced with path() or re_path(). For proper include() we also need an app_name specified in the urls.py we're including. --- api/urls.py | 6 +++--- contest/urls.py | 43 +++++++++++++++---------------------------- cqtu/urls.py | 33 +++++++++------------------------ 3 files changed, 27 insertions(+), 55 deletions(-) diff --git a/api/urls.py b/api/urls.py index 57fd854..00877cc 100644 --- a/api/urls.py +++ b/api/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import include, url +from django.urls import include, path from rest_framework import routers from .views import ContestViewSet, BandViewSet, FrequencyViewSet, EntryCategoryViewSet, ReferenceViewSet, QSOViewSet, \ @@ -15,6 +15,6 @@ router.register('shadowcalls', ShadowCallViewSet) router.register('profile', UserProfileViewSet, basename='profile') urlpatterns = [ - url(r'^', include(router.urls)), - url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), + path('', include(router.urls)), + path('api-auth/', include('rest_framework.urls', namespace='rest_framework')), ] diff --git a/contest/urls.py b/contest/urls.py index 0ce817a..9283ca5 100644 --- a/contest/urls.py +++ b/contest/urls.py @@ -1,35 +1,22 @@ -"""cqtu URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/1.10/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.conf.urls import url, include - 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) -""" -from django.conf.urls import url +from django.urls import re_path import contest.views as contest_views from contest.cbrparser import uploadCBR +app_name = 'context' + urlpatterns = [ - url(r'^$', contest_views.contestIndex, name='index'), - url(r'^regref/$', contest_views.registerRefs, name='registerRefs'), - url(r'^regref/edit/(?P\d+)/$', contest_views.updateRef, {"shadow": False}, name='updateRef'), - url(r'^regref/shadow/edit/(?P\d+)/$', contest_views.updateRef, {"shadow": True}, name='updateShadowRef'), - url(r'^regref/qsos/all/$', contest_views.viewAllQSOs, name='viewAllQSOs'), - url(r'^regref/qsos/user/(?P\d+)/$', contest_views.viewUserQSOs, name='viewUserQSOs'), - url(r'^overview/$', contest_views.overview, name='overview'), - url(r'^log/$', contest_views.log, name='log'), - url(r'^log/edit/(?P\d+)/$', contest_views.logEdit, name='logEdit'), - url(r'^log/delete/(?P\d+)/$', contest_views.logDelete, name='logDelete'), - url(r'^uploadcbr/$', uploadCBR, name='uploadCBR'), - url(r'^regref/recheckqsos/$', contest_views.recheckAllQSOs, name='recheckAllQSOs'), + re_path(r'^$', contest_views.contestIndex, name='index'), + re_path(r'^regref/$', contest_views.registerRefs, name='registerRefs'), + re_path(r'^regref/edit/(?P\d+)/$', contest_views.updateRef, {"shadow": False}, name='updateRef'), + re_path(r'^regref/shadow/edit/(?P\d+)/$', contest_views.updateRef, {"shadow": True}, name='updateShadowRef'), + re_path(r'^regref/qsos/all/$', contest_views.viewAllQSOs, name='viewAllQSOs'), + re_path(r'^regref/qsos/user/(?P\d+)/$', contest_views.viewUserQSOs, name='viewUserQSOs'), + re_path(r'^overview/$', contest_views.overview, name='overview'), + re_path(r'^log/$', contest_views.log, name='log'), + re_path(r'^log/edit/(?P\d+)/$', contest_views.logEdit, name='logEdit'), + re_path(r'^log/delete/(?P\d+)/$', contest_views.logDelete, name='logDelete'), + re_path(r'^uploadcbr/$', uploadCBR, name='uploadCBR'), + re_path(r'^regref/recheckqsos/$', contest_views.recheckAllQSOs, name='recheckAllQSOs'), ] diff --git a/cqtu/urls.py b/cqtu/urls.py index a954be5..72501c0 100644 --- a/cqtu/urls.py +++ b/cqtu/urls.py @@ -1,19 +1,4 @@ -"""cqtu URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/1.10/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.conf.urls import url, include - 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) -""" -from django.conf.urls import url, include +from django.urls import include, path from django.contrib import admin from django.contrib.auth import views as auth_views @@ -21,13 +6,13 @@ from contest.views import index, register, profile urlpatterns = [ - url('^$', index, name="index"), - url('^cqtufm2019/', include('contest.urls', namespace='contest')), + path('', index, name="index"), + path('cqtufm2019/', include('contest.urls', namespace='contest')), - url(r'^admin/', admin.site.urls), - url(r'^login/$', auth_views.login, name='login'), - url(r'^logout/$', auth_views.logout, {'next_page': '/'}, name='logout'), - url(r'^register/$', register, name='register'), - url(r'^profile/$', profile, name='profile'), - url(r'^api/', include('api.urls')), + path('admin/', admin.site.urls), + path('login/', auth_views.LoginView.as_view(), name='login'), + path('logout/', auth_views.LogoutView.as_view(), {'next_page': '/'}, name='logout'), + path('register/', register, name='register'), + path('profile/', profile, name='profile'), + path('api/', include('api.urls')), ]