From df41b5a05d4e00e80e73afe629072e37873e767a Mon Sep 17 00:00:00 2001 From: Sjoerd Job Postmus Date: Thu, 20 Oct 2016 19:29:04 +0200 Subject: Fixed #28593 -- Added a simplified URL routing syntax per DEP 0201. Thanks Aymeric Augustin for shepherding the DEP and patch review. Thanks Marten Kenbeek and Tim Graham for contributing to the code. Thanks Tom Christie, Shai Berger, and Tim Graham for the docs. --- docs/intro/tutorial04.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'docs/intro/tutorial04.txt') diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt index f320476548..6f685fc402 100644 --- a/docs/intro/tutorial04.txt +++ b/docs/intro/tutorial04.txt @@ -61,7 +61,7 @@ created a URLconf for the polls application that includes this line: .. snippet:: :filename: polls/urls.py - url(r'^(?P[0-9]+)/vote/$', views.vote, name='vote'), + path('/vote/', views.vote, name='vote'), We also created a dummy implementation of the ``vote()`` function. Let's create a real version. Add the following to ``polls/views.py``: @@ -237,20 +237,20 @@ First, open the ``polls/urls.py`` URLconf and change it like so: .. snippet:: :filename: polls/urls.py - from django.conf.urls import url + from django.urls import path from . import views app_name = 'polls' urlpatterns = [ - url(r'^$', views.IndexView.as_view(), name='index'), - url(r'^(?P[0-9]+)/$', views.DetailView.as_view(), name='detail'), - url(r'^(?P[0-9]+)/results/$', views.ResultsView.as_view(), name='results'), - url(r'^(?P[0-9]+)/vote/$', views.vote, name='vote'), + path('', views.IndexView.as_view(), name='index'), + path('/', views.DetailView.as_view(), name='detail'), + path('/results/', views.ResultsView.as_view(), name='results'), + path('/vote/', views.vote, name='vote'), ] -Note that the name of the matched pattern in the regexes of the second and third -patterns has changed from ```` to ````. +Note that the name of the matched pattern in the path strings of the second and +third patterns has changed from ```` to ````. Amend views ----------- -- cgit v1.3