diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt index 3728a098048ae..52c0869146b76 100644 --- a/docs/ref/models/instances.txt +++ b/docs/ref/models/instances.txt @@ -470,7 +470,7 @@ the URL. For example, if your URLconf contained a line such as:: Similarly, if you had a URLconf entry that looked like:: - (r'/archive/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', archive_view) + (r'/archive/(?P\d{4})/(?P\d{2})/(?P\d{2})/$', archive_view) ...you could reference this using ``permalink()`` as follows:: @@ -478,8 +478,8 @@ Similarly, if you had a URLconf entry that looked like:: def get_absolute_url(self): return ('archive_view', (), { 'year': self.created.year, - 'month': self.created.month, - 'day': self.created.day}) + 'month': self.created.strftime('%m'), + 'day': self.created.strftime('%d')}) Notice that we specify an empty sequence for the second parameter in this case, 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 08dd94d8382f8..a5cf21bb658f7 100644 --- a/docs/topics/http/urls.txt +++ b/docs/topics/http/urls.txt @@ -103,8 +103,8 @@ Example requests: * ``/articles/2003`` would not match any of these patterns, because each pattern requires that the URL end with a slash. - * ``/articles/2003/03/3/`` would match the final pattern. Django would call - the function ``news.views.article_detail(request, '2003', '03', '3')``. + * ``/articles/2003/03/03/`` would match the final pattern. Django would call + the function ``news.views.article_detail(request, '2003', '03', '03')``. .. _Dive Into Python's explanation: http://diveintopython.org/regular_expressions/street_addresses.html#re.matching.2.3 @@ -127,7 +127,7 @@ Here's the above example URLconf, rewritten to use named groups:: (r'^articles/2003/$', 'news.views.special_case_2003'), (r'^articles/(?P\d{4})/$', 'news.views.year_archive'), (r'^articles/(?P\d{4})/(?P\d{2})/$', 'news.views.month_archive'), - (r'^articles/(?P\d{4})/(?P\d{2})/(?P\d+)/$', 'news.views.article_detail'), + (r'^articles/(?P\d{4})/(?P\d{2})/(?P\d{2})/$', 'news.views.article_detail'), ) This accomplishes exactly the same thing as the previous example, with one @@ -138,8 +138,8 @@ arguments rather than positional arguments. For example: ``news.views.month_archive(request, year='2005', month='03')``, instead of ``news.views.month_archive(request, '2005', '03')``. - * A request to ``/articles/2003/03/3/`` would call the function - ``news.views.article_detail(request, year='2003', month='03', day='3')``. + * A request to ``/articles/2003/03/03/`` would call the function + ``news.views.article_detail(request, year='2003', month='03', day='03')``. In practice, this means your URLconfs are slightly more explicit and less prone to argument-order bugs -- and you can reorder the arguments in your views'