diff options
| author | Seohong Park <artberryx@naver.com> | 2018-02-21 11:31:30 +0900 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-02-20 21:31:52 -0500 |
| commit | ea0dc5df094c25ff7484353126cba89d1a281889 (patch) | |
| tree | c2d73c0f16d8e7ac164563aacbab7b9da629b591 | |
| parent | 0993aee31d47c977801266a0c22f1c03d6ede084 (diff) | |
[2.0.x] Fixed #29146 -- Readded ^ and $ inadvertently removed from re_path() examples.
Backport of 97168605965143f02c27dac718b6b3e317a4be26 from master
| -rw-r--r-- | docs/topics/http/urls.txt | 10 |
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, |
