summaryrefslogtreecommitdiff
path: root/docs/topics
diff options
context:
space:
mode:
authorSeohong Park <artberryx@naver.com>2018-02-21 11:31:30 +0900
committerTim Graham <timograham@gmail.com>2018-02-20 21:31:30 -0500
commit97168605965143f02c27dac718b6b3e317a4be26 (patch)
tree5293b7c1d939f31d470407a36fb609b125a524f6 /docs/topics
parent195610227dab298e2d9321611f1e18ab1ce7a607 (diff)
Fixed #29146 -- Readded ^ and $ inadvertently removed from re_path() examples.
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/http/urls.txt10
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
index 613069327c..5d28ac4272 100644
--- a/docs/topics/http/urls.txt
+++ b/docs/topics/http/urls.txt
@@ -199,9 +199,9 @@ Here's the example URLconf from earlier, rewritten using regular expressions::
urlpatterns = [
path('articles/2003/', views.special_case_2003),
- re_path('articles/(?P<year>[0-9]{4})/', views.year_archive),
- re_path('articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/', views.month_archive),
- re_path('articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<slug>[\w-_]+)/', views.article_detail),
+ re_path(r'^articles/(?P<year>[0-9]{4})/$', views.year_archive),
+ re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', views.month_archive),
+ re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<slug>[\w-_]+)/$', views.article_detail),
]
This accomplishes roughly the same thing as the previous example, except:
@@ -243,8 +243,8 @@ following URL patterns which optionally take a page argument::
from django.urls import re_path
urlpatterns = [
- re_path(r'blog/(page-(\d+)/)?$', blog_articles), # bad
- re_path(r'comments/(?:page-(?P<page_number>\d+)/)?$', comments), # good
+ re_path(r'^blog/(page-(\d+)/)?$', blog_articles), # bad
+ re_path(r'^comments/(?:page-(?P<page_number>\d+)/)?$', comments), # good
]
Both patterns use nested arguments and will resolve: for example,