diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt
index 2053788..8809eaf 100644
a
|
b
|
method that looked like this::
|
497 | 497 | |
498 | 498 | Similarly, if you had a URLconf entry that looked like:: |
499 | 499 | |
500 | | (r'/archive/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', archive_view) |
| 500 | (r'/archive/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', archive_view) |
501 | 501 | |
502 | 502 | ...you could reference this using ``permalink()`` as follows:: |
503 | 503 | |
… |
… |
Similarly, if you had a URLconf entry that looked like::
|
505 | 505 | def get_absolute_url(self): |
506 | 506 | return ('archive_view', (), { |
507 | 507 | 'year': self.created.year, |
508 | | 'month': self.created.month, |
509 | | 'day': self.created.day}) |
| 508 | 'month': self.created.strftime('%m'), |
| 509 | 'day': self.created.strftime('%d')}) |
510 | 510 | |
511 | 511 | Notice that we specify an empty sequence for the second parameter in this case, |
512 | 512 | because we only want to pass keyword parameters, not positional ones. |
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
index 4bb3b78..3f68cdb 100644
a
|
b
|
Example requests:
|
105 | 105 | * ``/articles/2003`` would not match any of these patterns, because each |
106 | 106 | pattern requires that the URL end with a slash. |
107 | 107 | |
108 | | * ``/articles/2003/03/3/`` would match the final pattern. Django would call |
109 | | the function ``news.views.article_detail(request, '2003', '03', '3')``. |
| 108 | * ``/articles/2003/03/03/`` would match the final pattern. Django would call |
| 109 | the function ``news.views.article_detail(request, '2003', '03', '03')``. |
110 | 110 | |
111 | 111 | .. _Dive Into Python's explanation: http://diveintopython.org/regular_expressions/street_addresses.html#re.matching.2.3 |
112 | 112 | |
… |
… |
Here's the above example URLconf, rewritten to use named groups::
|
129 | 129 | (r'^articles/2003/$', 'news.views.special_case_2003'), |
130 | 130 | (r'^articles/(?P<year>\d{4})/$', 'news.views.year_archive'), |
131 | 131 | (r'^articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'news.views.month_archive'), |
132 | | (r'^articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d+)/$', 'news.views.article_detail'), |
| 132 | (r'^articles/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', 'news.views.article_detail'), |
133 | 133 | ) |
134 | 134 | |
135 | 135 | This accomplishes exactly the same thing as the previous example, with one |
… |
… |
arguments rather than positional arguments. For example:
|
140 | 140 | ``news.views.month_archive(request, year='2005', month='03')``, instead |
141 | 141 | of ``news.views.month_archive(request, '2005', '03')``. |
142 | 142 | |
143 | | * A request to ``/articles/2003/03/3/`` would call the function |
144 | | ``news.views.article_detail(request, year='2003', month='03', day='3')``. |
| 143 | * A request to ``/articles/2003/03/03/`` would call the function |
| 144 | ``news.views.article_detail(request, year='2003', month='03', day='03')``. |
145 | 145 | |
146 | 146 | In practice, this means your URLconfs are slightly more explicit and less prone |
147 | 147 | to argument-order bugs -- and you can reorder the arguments in your views' |