Changeset - 2a99a0c81a5d
[Not reviewed]
0 6 0
Ben Sturmfels (bsturmfels) - 1 month ago 2024-03-18 06:51:33
ben@sturm.com.au
Switch from `url()` to `path()`

Path is the new way to handle simpler routing rules.
6 files changed with 30 insertions and 26 deletions:
0 comments (0 inline, 0 general)
conservancy/contacts/urls.py
Show inline comments
 
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),
 
]
conservancy/contacts/views.py
Show inline comments
 
from django import forms
 
from django.forms import ModelForm
 
from django.shortcuts import render
 

	
 
from .models import ContactEntry
 

	
 

	
conservancy/contractpatch/urls.py
Show inline comments
 
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),
 
]
conservancy/events/urls.py
Show inline comments
 
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(),
 
    'date_field': 'date',
 
    'allow_future': True,
 
}
...
 
@@ -17,9 +18,9 @@ info_dict = {
 
# urlpatterns += patterns('www.events.views',
 
#     (r'^/?$', 'custom_index', dict(info_dict, queryset=Event.past.all(), paginate_by=10)),
 
#     (r'^(?P<year>\d{4})/(?P<slug>[-\w]+)/$', 'event_detail', dict(info_dict, slug_field='slug')),
 
#     (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)),
 
]
conservancy/podjango/urls.py
Show inline comments
...
 
@@ -17,13 +17,13 @@
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
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,
 
    MonthArchiveView,
 
    YearArchiveView,
 
)
...
 
@@ -41,22 +41,22 @@ info_dict = {
 
    'date_field': 'pub_date',
 
    'extra_context': extra_context,
 
    'template_name': 'podjango/cast/cast_detail.html',
 
}
 

	
 
urlpatterns = [
 
    url(r'^$', frontpage.view, name='cast-home'),
 
    url(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$', DateDetailView.as_view(**info_dict), name='detail'),
 
    url(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', DayArchiveView.as_view(**info_dict), name='day-archive'),
 
    url(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', MonthArchiveView.as_view(**info_dict), name='month-archive'),
 
    url(r'^(?P<year>\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('<int:year>/<month>/<int:day>/<slug:slug>/', DateDetailView.as_view(**info_dict), name='detail'),
 
    path('<int:year>/<month>/<int:day>/', DayArchiveView.as_view(**info_dict), name='day-archive'),
 
    path('<int:year>/<month>/', MonthArchiveView.as_view(**info_dict), name='month-archive'),
 
    path('<int:year>/', 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:
 
    from django.conf.urls.static import static
 
    urlpatterns += static('/', document_root='podjango/static')
 

	
conservancy/summit_registration/urls.py
Show inline comments
 
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),
 
]
0 comments (0 inline, 0 general)