From 2a99a0c81a5de59041e328d0d997f69f42c11bdb 2024-03-18 06:51:33 From: Ben Sturmfels Date: 2024-03-18 06:51:33 Subject: [PATCH] Switch from `url()` to `path()` Path is the new way to handle simpler routing rules. --- diff --git a/conservancy/contacts/urls.py b/conservancy/contacts/urls.py index bb0ae07c7b344a57fb943b368db39c4b47bc184c..661e68911f8d37eaf233eebb0b5de3bde303ac1c 100644 --- a/conservancy/contacts/urls.py +++ b/conservancy/contacts/urls.py @@ -1,5 +1,7 @@ -from django.conf.urls import include, patterns, url +from django.urls import path -urlpatterns = patterns('www.contacts.views', - (r'^/?$', 'subscribe'), -) +from .views import subscribe + +urlpatterns = [ + path('', subscribe), +] diff --git a/conservancy/contacts/views.py b/conservancy/contacts/views.py index 154251a872d93b44a2e1ef68548572ef409a9c29..95ccfc09340d49cbf7a6e7cd3ffc76a2bdfbc93b 100644 --- a/conservancy/contacts/views.py +++ b/conservancy/contacts/views.py @@ -1,4 +1,3 @@ -from django import forms from django.forms import ModelForm from django.shortcuts import render diff --git a/conservancy/contractpatch/urls.py b/conservancy/contractpatch/urls.py index 8943efb944569ba468d163f395e083cd753803f4..a21c1e833054322fc69becac450182fb0a836f5e 100644 --- a/conservancy/contractpatch/urls.py +++ b/conservancy/contractpatch/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import include, url +from django.urls import path from . import views as cpatch_views urlpatterns = [ - url(r'', cpatch_views.index), + path('', cpatch_views.index), ] diff --git a/conservancy/events/urls.py b/conservancy/events/urls.py index 2f62a4ce2e04be67a5f386d61f73d61595cf6911..94249ed11175b8c9ee96e27d67f710712058b31a 100644 --- a/conservancy/events/urls.py +++ b/conservancy/events/urls.py @@ -1,6 +1,7 @@ -from django.conf.urls import include, patterns, url +from django.urls import re_path from .models import Event +from .views import custom_index info_dict = { 'queryset': Event.objects.all(), @@ -20,6 +21,6 @@ info_dict = { # (r'^ics/$', 'future_event_ics', info_dict), # ) -urlpatterns = patterns('www.events.views', - (r'^.*$', 'custom_index', dict(info_dict, queryset=Event.past.all(), paginate_by=10)), -) +urlpatterns = [ + re_path('', custom_index, dict(info_dict, queryset=Event.past.all(), paginate_by=10)), +] diff --git a/conservancy/podjango/urls.py b/conservancy/podjango/urls.py index 1fab03912cd286db62dc1e23b5e00d4921ad6173..0d6896a399a27fdf3988e05c32ac9b0138a924f9 100644 --- a/conservancy/podjango/urls.py +++ b/conservancy/podjango/urls.py @@ -20,7 +20,7 @@ import datetime from django.conf import settings -from django.conf.urls import url +from django.urls import path from django.views.generic.dates import ( DateDetailView, DayArchiveView, @@ -44,16 +44,16 @@ info_dict = { } urlpatterns = [ - url(r'^$', frontpage.view, name='cast-home'), - url(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?P[-\w]+)/$', DateDetailView.as_view(**info_dict), name='detail'), - url(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/$', DayArchiveView.as_view(**info_dict), name='day-archive'), - url(r'^(?P\d{4})/(?P[a-z]{3})/$', MonthArchiveView.as_view(**info_dict), name='month-archive'), - url(r'^(?P\d{4})/$', YearArchiveView.as_view(**info_dict), name='year-archive'), - url(r'^all/$', custom_index, dict(info_dict, paginate_by=20), name='cast'), - url(r'^query/$', query, name='query'), - url(r'^feeds/ogg/$', OggCastFeed(), name='feed-ogg'), - url(r'^feeds/mp3/$', Mp3CastFeed(), name='feed-mp3'), - url(r'^feeds/$', view, name='feeds'), + path('', frontpage.view, name='cast-home'), + path('////', DateDetailView.as_view(**info_dict), name='detail'), + path('///', DayArchiveView.as_view(**info_dict), name='day-archive'), + path('//', MonthArchiveView.as_view(**info_dict), name='month-archive'), + path('/', YearArchiveView.as_view(**info_dict), name='year-archive'), + path('all/', custom_index, dict(info_dict, paginate_by=20), name='cast'), + path('query/', query, name='query'), + path('feeds/ogg/', OggCastFeed(), name='feed-ogg'), + path('feeds/mp3/', Mp3CastFeed(), name='feed-mp3'), + path('feeds/', view, name='feeds'), ] if settings.DEBUG: diff --git a/conservancy/summit_registration/urls.py b/conservancy/summit_registration/urls.py index 3245b9d2ea97053354f741f8422e05af0dffa876..7457d87e5a621fdb88e6a2e74a20340979e94eea 100644 --- a/conservancy/summit_registration/urls.py +++ b/conservancy/summit_registration/urls.py @@ -1,5 +1,7 @@ -from django.conf.urls import include, patterns, url +from django.urls import path -urlpatterns = patterns('www.summit_registration.views', - (r'^/?$', 'register'), -) +from .views import register + +urlpatterns = [ + path('', register), +]