summaryrefslogtreecommitdiff
path: root/docs/topics
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/topics
parent030dd4f72ca4d84c0a5e09ee625123d03651fdd1 (diff)
Fixed #22378 -- Updated \d to [0-9]+ in urlpatterns of docs and tests.
Thanks tomwys for the suggestion.
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/cache.txt6
-rw-r--r--docs/topics/class-based-views/generic-display.txt2
-rw-r--r--docs/topics/class-based-views/generic-editing.txt4
-rw-r--r--docs/topics/class-based-views/mixins.txt2
-rw-r--r--docs/topics/http/urls.txt32
5 files changed, 23 insertions, 23 deletions
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt
index feeaf37a47..a5f9b3451c 100644
--- a/docs/topics/cache.txt
+++ b/docs/topics/cache.txt
@@ -533,7 +533,7 @@ multiple URLs point at the same view, each URL will be cached separately.
Continuing the ``my_view`` example, if your URLconf looks like this::
urlpatterns = [
- url(r'^foo/(\d{1,2})/$', my_view),
+ url(r'^foo/([0-9]{1,2})/$', my_view),
]
then requests to ``/foo/1/`` and ``/foo/23/`` will be cached separately, as
@@ -579,7 +579,7 @@ Doing so is easy: simply wrap the view function with ``cache_page`` when you
refer to it in the URLconf. Here's the old URLconf from earlier::
urlpatterns = [
- url(r'^foo/(\d{1,2})/$', my_view),
+ url(r'^foo/([0-9]{1,2})/$', my_view),
]
Here's the same thing, with ``my_view`` wrapped in ``cache_page``::
@@ -587,7 +587,7 @@ Here's the same thing, with ``my_view`` wrapped in ``cache_page``::
from django.views.decorators.cache import cache_page
urlpatterns = [
- url(r'^foo/(\d{1,2})/$', cache_page(60 * 15)(my_view)),
+ url(r'^foo/([0-9]{1,2})/$', cache_page(60 * 15)(my_view)),
]
.. templatetag:: cache
diff --git a/docs/topics/class-based-views/generic-display.txt b/docs/topics/class-based-views/generic-display.txt
index 98d2b79d32..54b75ce557 100644
--- a/docs/topics/class-based-views/generic-display.txt
+++ b/docs/topics/class-based-views/generic-display.txt
@@ -401,7 +401,7 @@ custom view::
urlpatterns = [
#...
- url(r'^authors/(?P<pk>\d+)/$', AuthorDetailView.as_view(), name='author-detail'),
+ url(r'^authors/(?P<pk>[0-9]+)/$', AuthorDetailView.as_view(), name='author-detail'),
]
Then we'd write our new view -- ``get_object`` is the method that retrieves the
diff --git a/docs/topics/class-based-views/generic-editing.txt b/docs/topics/class-based-views/generic-editing.txt
index 2587c9426d..74d19d53b1 100644
--- a/docs/topics/class-based-views/generic-editing.txt
+++ b/docs/topics/class-based-views/generic-editing.txt
@@ -147,8 +147,8 @@ Finally, we hook these new views into the URLconf::
urlpatterns = [
# ...
url(r'author/add/$', AuthorCreate.as_view(), name='author_add'),
- url(r'author/(?P<pk>\d+)/$', AuthorUpdate.as_view(), name='author_update'),
- url(r'author/(?P<pk>\d+)/delete/$', AuthorDelete.as_view(), name='author_delete'),
+ url(r'author/(?P<pk>[0-9]+)/$', AuthorUpdate.as_view(), name='author_update'),
+ url(r'author/(?P<pk>[0-9]+)/delete/$', AuthorDelete.as_view(), name='author_delete'),
]
.. note::
diff --git a/docs/topics/class-based-views/mixins.txt b/docs/topics/class-based-views/mixins.txt
index 00729f36f9..40ba615088 100644
--- a/docs/topics/class-based-views/mixins.txt
+++ b/docs/topics/class-based-views/mixins.txt
@@ -261,7 +261,7 @@ We can hook this into our URLs easily enough::
urlpatterns = [
#...
- url(r'^author/(?P<pk>\d+)/interest/$', RecordInterest.as_view(), name='author-interest'),
+ url(r'^author/(?P<pk>[0-9]+)/interest/$', RecordInterest.as_view(), name='author-interest'),
]
Note the ``pk`` named group, which
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
index 05525cc715..92ec4bb0e9 100644
--- a/docs/topics/http/urls.txt
+++ b/docs/topics/http/urls.txt
@@ -76,9 +76,9 @@ Here's a sample URLconf::
urlpatterns = [
url(r'^articles/2003/$', 'news.views.special_case_2003'),
- 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'),
]
Notes:
@@ -133,9 +133,9 @@ Here's the above example URLconf, rewritten to use named groups::
urlpatterns = [
url(r'^articles/2003/$', 'news.views.special_case_2003'),
- url(r'^articles/(?P<year>\d{4})/$', 'news.views.year_archive'),
- url(r'^articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'news.views.month_archive'),
- url(r'^articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', 'news.views.article_detail'),
+ url(r'^articles/(?P<year>[0-9]{4})/$', 'news.views.year_archive'),
+ url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', 'news.views.month_archive'),
+ url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$', 'news.views.article_detail'),
]
This accomplishes exactly the same thing as the previous example, with one
@@ -191,10 +191,10 @@ Each captured argument is sent to the view as a plain Python string, regardless
of what sort of match the regular expression makes. For example, in this
URLconf line::
- url(r'^articles/(?P<year>\d{4})/$', 'news.views.year_archive'),
+ url(r'^articles/(?P<year>[0-9]{4})/$', 'news.views.year_archive'),
...the ``year`` argument to ``news.views.year_archive()`` will be a string, not
-an integer, even though the ``\d{4}`` will only match integer strings.
+an integer, even though the ``[0-9]{4}`` will only match integer strings.
Specifying defaults for view arguments
======================================
@@ -207,7 +207,7 @@ Here's an example URLconf and view::
urlpatterns = [
url(r'^blog/$', 'blog.views.page'),
- url(r'^blog/page(?P<num>\d+)/$', 'blog.views.page'),
+ url(r'^blog/page(?P<num>[0-9]+)/$', 'blog.views.page'),
]
# View (in blog/views.py)
@@ -291,7 +291,7 @@ Another possibility is to include additional URL patterns by using a list of
from django.conf.urls import include, url
extra_patterns = [
- url(r'^reports/(?P<id>\d+)/$', 'credit.views.report'),
+ url(r'^reports/(?P<id>[0-9]+)/$', 'credit.views.report'),
url(r'^charge/$', 'credit.views.charge'),
]
@@ -377,7 +377,7 @@ For example::
from . import views
urlpatterns = [
- url(r'^blog/(?P<year>\d{4})/$', views.year_archive, {'foo': 'bar'}),
+ url(r'^blog/(?P<year>[0-9]{4})/$', views.year_archive, {'foo': 'bar'}),
]
In this example, for a request to ``/blog/2005/``, Django will call
@@ -558,7 +558,7 @@ Consider again this URLconf entry::
urlpatterns = [
#...
- url(r'^articles/(\d{4})/$', 'news.views.year_archive'),
+ url(r'^articles/([0-9]{4})/$', 'news.views.year_archive'),
#...
]
@@ -610,8 +610,8 @@ view::
from mysite.views import archive
urlpatterns = [
- url(r'^archive/(\d{4})/$', archive),
- url(r'^archive-summary/(\d{4})/$', archive, {'summary': True}),
+ url(r'^archive/([0-9]{4})/$', archive),
+ url(r'^archive-summary/([0-9]{4})/$', archive, {'summary': True}),
]
This is completely valid, but it leads to problems when you try to do reverse
@@ -631,8 +631,8 @@ Here's the above example, rewritten to use named URL patterns::
from mysite.views import archive
urlpatterns = [
- url(r'^archive/(\d{4})/$', archive, name="full-archive"),
- url(r'^archive-summary/(\d{4})/$', archive, {'summary': True}, name="arch-summary"),
+ url(r'^archive/([0-9]{4})/$', archive, name="full-archive"),
+ url(r'^archive-summary/([0-9]{4})/$', archive, {'summary': True}, name="arch-summary"),
]
With these names in place (``full-archive`` and ``arch-summary``), you can