Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.3.X] Fixed #16109: Corrected an inconsistency in URLconf examples …

…for matching a numeric month. Backport of [16811] from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16812 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 16787c690396d5ce4d24070bd910e23ba6559c84 1 parent f242c02
James Bennett authored September 11, 2011
6  docs/ref/models/instances.txt
@@ -470,7 +470,7 @@ the URL. For example, if your URLconf contained a line such as::
470 470
 
471 471
 Similarly, if you had a URLconf entry that looked like::
472 472
 
473  
-    (r'/archive/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', archive_view)
  473
+    (r'/archive/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', archive_view)
474 474
 
475 475
 ...you could reference this using ``permalink()`` as follows::
476 476
 
@@ -478,8 +478,8 @@ Similarly, if you had a URLconf entry that looked like::
478 478
     def get_absolute_url(self):
479 479
         return ('archive_view', (), {
480 480
             'year': self.created.year,
481  
-            'month': self.created.month,
482  
-            'day': self.created.day})
  481
+            'month': self.created.strftime('%m'),
  482
+            'day': self.created.strftime('%d')})
483 483
 
484 484
 Notice that we specify an empty sequence for the second parameter in this case,
485 485
 because we only want to pass keyword parameters, not positional ones.
10  docs/topics/http/urls.txt
@@ -103,8 +103,8 @@ Example requests:
103 103
     * ``/articles/2003`` would not match any of these patterns, because each
104 104
       pattern requires that the URL end with a slash.
105 105
 
106  
-    * ``/articles/2003/03/3/`` would match the final pattern. Django would call
107  
-      the function ``news.views.article_detail(request, '2003', '03', '3')``.
  106
+    * ``/articles/2003/03/03/`` would match the final pattern. Django would call
  107
+      the function ``news.views.article_detail(request, '2003', '03', '03')``.
108 108
 
109 109
 .. _Dive Into Python's explanation: http://diveintopython.org/regular_expressions/street_addresses.html#re.matching.2.3
110 110
 
@@ -127,7 +127,7 @@ Here's the above example URLconf, rewritten to use named groups::
127 127
         (r'^articles/2003/$', 'news.views.special_case_2003'),
128 128
         (r'^articles/(?P<year>\d{4})/$', 'news.views.year_archive'),
129 129
         (r'^articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'news.views.month_archive'),
130  
-        (r'^articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d+)/$', 'news.views.article_detail'),
  130
+        (r'^articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', 'news.views.article_detail'),
131 131
     )
132 132
 
133 133
 This accomplishes exactly the same thing as the previous example, with one
@@ -138,8 +138,8 @@ arguments rather than positional arguments. For example:
138 138
       ``news.views.month_archive(request, year='2005', month='03')``, instead
139 139
       of ``news.views.month_archive(request, '2005', '03')``.
140 140
 
141  
-    * A request to ``/articles/2003/03/3/`` would call the function
142  
-      ``news.views.article_detail(request, year='2003', month='03', day='3')``.
  141
+    * A request to ``/articles/2003/03/03/`` would call the function
  142
+      ``news.views.article_detail(request, year='2003', month='03', day='03')``.
143 143
 
144 144
 In practice, this means your URLconfs are slightly more explicit and less prone
145 145
 to argument-order bugs -- and you can reorder the arguments in your views'

0 notes on commit 16787c6

Please sign in to comment.
Something went wrong with that request. Please try again.