diff options
| author | Sjoerd Job Postmus <sjoerdjob@sjec.nl> | 2016-10-20 19:29:04 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-09-20 18:04:42 -0400 |
| commit | df41b5a05d4e00e80e73afe629072e37873e767a (patch) | |
| tree | baaf71ae695e2d3af604ea0d663284cb406c71e4 /docs/intro/tutorial04.txt | |
| parent | c4c128d67c7dc2830631c6859a204c9d259f1fb1 (diff) | |
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.
Diffstat (limited to 'docs/intro/tutorial04.txt')
| -rw-r--r-- | docs/intro/tutorial04.txt | 16 |
1 files changed, 8 insertions, 8 deletions
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<question_id>[0-9]+)/vote/$', views.vote, name='vote'), + path('<int:question_id>/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<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'), - url(r'^(?P<pk>[0-9]+)/results/$', views.ResultsView.as_view(), name='results'), - url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'), + path('', views.IndexView.as_view(), name='index'), + path('<int:pk>/', views.DetailView.as_view(), name='detail'), + path('<int:pk>/results/', views.ResultsView.as_view(), name='results'), + path('<int:question_id>/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 ``<question_id>`` to ``<pk>``. +Note that the name of the matched pattern in the path strings of the second and +third patterns has changed from ``<question_id>`` to ``<pk>``. Amend views ----------- |
