summaryrefslogtreecommitdiff
path: root/docs/intro
diff options
context:
space:
mode:
authorchriscauley <chris@lablackey.com>2014-04-14 14:12:44 -0400
committerTim Graham <timograham@gmail.com>2014-04-16 20:36:29 -0400
commit66ec9ee441618894c1ccebdcdd5eb4d7fbf4a6d3 (patch)
tree956a7d4f6e3b1c348505a3f2d23c7813c6c362b8 /docs/intro
parent030dd4f72ca4d84c0a5e09ee625123d03651fdd1 (diff)
Fixed #22378 -- Updated \d to [0-9]+ in urlpatterns of docs and tests.
Thanks tomwys for the suggestion.
Diffstat (limited to 'docs/intro')
-rw-r--r--docs/intro/overview.txt6
-rw-r--r--docs/intro/tutorial03.txt16
-rw-r--r--docs/intro/tutorial04.txt8
3 files changed, 15 insertions, 15 deletions
diff --git a/docs/intro/overview.txt b/docs/intro/overview.txt
index 42d80f66cd..685666f8cb 100644
--- a/docs/intro/overview.txt
+++ b/docs/intro/overview.txt
@@ -187,9 +187,9 @@ example above::
from django.conf.urls import url
urlpatterns = [
- url(r'^articles/(\d{4})/$', 'news.views.year_archive'),
- url(r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'),
- url(r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'),
+ url(r'^articles/([0-9]{4})/$', 'news.views.year_archive'),
+ url(r'^articles/([0-9]{4})/([0-9]{2})/$', 'news.views.month_archive'),
+ url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', 'news.views.article_detail'),
]
The code above maps URLs, as simple `regular expressions`_, to the location of
diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt
index 3d4f65a720..1d25a58711 100644
--- a/docs/intro/tutorial03.txt
+++ b/docs/intro/tutorial03.txt
@@ -215,11 +215,11 @@ Wire these new views into the ``polls.urls`` module by adding the following
# ex: /polls/
url(r'^$', views.index, name='index'),
# ex: /polls/5/
- url(r'^(?P<question_id>\d+)/$', views.detail, name='detail'),
+ url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
# ex: /polls/5/results/
- url(r'^(?P<question_id>\d+)/results/$', views.results, name='results'),
+ url(r'^(?P<question_id>[0-9]+)/results/$', views.results, name='results'),
# ex: /polls/5/vote/
- url(r'^(?P<question_id>\d+)/vote/$', views.vote, name='vote'),
+ url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),
]
Take a look in your browser, at "/polls/34/". It'll run the ``detail()``
@@ -251,15 +251,15 @@ Here's what happens if a user goes to "/polls/34/" in this system:
* Then, Django will strip off the matching text (``"polls/"``) and send the
remaining text -- ``"34/"`` -- to the 'polls.urls' URLconf for
- further processing which matches ``r'^(?P<question_id>\d+)/$'`` resulting in a
+ further processing which matches ``r'^(?P<question_id>[0-9]+)/$'`` resulting in a
call to the ``detail()`` view like so::
detail(request=<HttpRequest object>, question_id='34')
-The ``question_id='34'`` part comes from ``(?P<question_id>\d+)``. Using parentheses
+The ``question_id='34'`` part comes from ``(?P<question_id>[0-9]+)``. Using parentheses
around a pattern "captures" the text matched by that pattern and sends it as an
argument to the view function; ``?P<question_id>`` defines the name that will
-be used to identify the matched pattern; and ``\d+`` is a regular expression to
+be used to identify the matched pattern; and ``[0-9]+`` is a regular expression to
match a sequence of digits (i.e., a number).
Because the URL patterns are regular expressions, there really is no limit on
@@ -554,7 +554,7 @@ defined below::
...
# the 'name' value as called by the {% url %} template tag
- url(r'^(?P<question_id>\d+)/$', views.detail, name='detail'),
+ url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
...
If you want to change the URL of the polls detail view to something else,
@@ -563,7 +563,7 @@ template (or templates) you would change it in ``polls/urls.py``::
...
# added the word 'specifics'
- url(r'^specifics/(?P<question_id>\d+)/$', views.detail, name='detail'),
+ url(r'^specifics/(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
...
Namespacing URL names
diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt
index 63d12d1a68..5b46dc0bb8 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>\d+)/vote/$', views.vote, name='vote'),
+ url(r'^(?P<question_id>[0-9]+)/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``:
@@ -228,9 +228,9 @@ First, open the ``polls/urls.py`` URLconf and change it like so:
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
- url(r'^(?P<pk>\d+)/$', views.DetailView.as_view(), name='detail'),
- url(r'^(?P<pk>\d+)/results/$', views.ResultsView.as_view(), name='results'),
- url(r'^(?P<question_id>\d+)/vote/$', views.vote, name='vote'),
+ 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'),
]
Amend views