From 97168605965143f02c27dac718b6b3e317a4be26 Mon Sep 17 00:00:00 2001 From: Seohong Park Date: Wed, 21 Feb 2018 11:31:30 +0900 Subject: [PATCH] Fixed #29146 -- Readded ^ and $ inadvertently removed from re_path() examples. --- docs/topics/http/urls.txt | 10 +++++----- 1 file 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[0-9]{4})/', views.year_archive), - re_path('articles/(?P[0-9]{4})/(?P[0-9]{2})/', views.month_archive), - re_path('articles/(?P[0-9]{4})/(?P[0-9]{2})/(?P[\w-_]+)/', views.article_detail), + re_path(r'^articles/(?P[0-9]{4})/$', views.year_archive), + re_path(r'^articles/(?P[0-9]{4})/(?P[0-9]{2})/$', views.month_archive), + re_path(r'^articles/(?P[0-9]{4})/(?P[0-9]{2})/(?P[\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\d+)/)?$', comments), # good + re_path(r'^blog/(page-(\d+)/)?$', blog_articles), # bad + re_path(r'^comments/(?:page-(?P\d+)/)?$', comments), # good ] Both patterns use nested arguments and will resolve: for example,