summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Schäpers <christopher@schaepers.it>2017-09-25 19:06:11 +0200
committerTim Graham <timograham@gmail.com>2017-09-25 13:11:07 -0400
commitecea60fee884bc41613b8afcb4cca39c8f2fa538 (patch)
tree3982d3cf7739f01f73558c18bf2c1cfd1df056e6
parentc67dce911e513b617adf1329fcd168ae96385fd5 (diff)
[2.0.x] Fixed #28627 -- Added slug converter to some path() examples in docs.
Backport of 6da140724dba546d2f3aced1308e617747b0385c from master
-rw-r--r--docs/ref/class-based-views/generic-display.txt2
-rw-r--r--docs/topics/http/urls.txt4
-rw-r--r--docs/topics/i18n/translation.txt8
3 files changed, 7 insertions, 7 deletions
diff --git a/docs/ref/class-based-views/generic-display.txt b/docs/ref/class-based-views/generic-display.txt
index 16975bdbea..8ebe871685 100644
--- a/docs/ref/class-based-views/generic-display.txt
+++ b/docs/ref/class-based-views/generic-display.txt
@@ -59,7 +59,7 @@ many projects they are typically the most commonly used views.
from article.views import ArticleDetailView
urlpatterns = [
- path('<slug>/', ArticleDetailView.as_view(), name='article-detail'),
+ path('<slug:slug>/', ArticleDetailView.as_view(), name='article-detail'),
]
**Example myapp/article_detail.html**:
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
index 449f421775..92303a408a 100644
--- a/docs/topics/http/urls.txt
+++ b/docs/topics/http/urls.txt
@@ -80,7 +80,7 @@ Here's a sample URLconf::
path('articles/2003/', views.special_case_2003),
path('articles/<int:year>/', views.year_archive),
path('articles/<int:year>/<int:month>/', views.month_archive),
- path('articles/<int:year>/<int:month>/<slug>/', views.article_detail),
+ path('articles/<int:year>/<int:month>/<slug:slug>/', views.article_detail),
]
Notes:
@@ -200,7 +200,7 @@ Here's the example URLconf from earlier, rewritten using regular expressions::
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>[^/]+)/', views.article_detail),
+ re_path('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:
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt
index dcecbf61a5..2bdf40fea1 100644
--- a/docs/topics/i18n/translation.txt
+++ b/docs/topics/i18n/translation.txt
@@ -1315,8 +1315,8 @@ Example URL patterns::
news_patterns = ([
path('', news_views.index, name='index'),
- path('category/<slug>/', news_views.category, name='category'),
- path('<slug>/', news_views.details, name='detail'),
+ path('category/<slug:slug>/', news_views.category, name='category'),
+ path('<slug:slug>/', news_views.details, name='detail'),
], 'news')
urlpatterns += i18n_patterns(
@@ -1385,8 +1385,8 @@ URL patterns can also be marked translatable using the
news_patterns = ([
path('', news_views.index, name='index'),
- path(_('category/<slug>/'), news_views.category, name='category'),
- path('<slug>/', news_views.details, name='detail'),
+ path(_('category/<slug:slug>/'), news_views.category, name='category'),
+ path('<slug:slug>/', news_views.details, name='detail'),
], 'news')
urlpatterns += i18n_patterns(