Ticket #9472: urls.txt.diff
File urls.txt.diff, 1.2 KB (added by , 16 years ago) |
---|
-
(a) urls.txt vs. (b) (current
a b 227 227 optional extra arguments dictionary. For example:: 228 228 229 229 urlpatterns = patterns('', 230 url(r' /index/$', index_view, name="main-view"),230 url(r'^index/$', index_view, name="main-view"), 231 231 ... 232 232 ) 233 233 … … 539 539 view:: 540 540 541 541 urlpatterns = patterns('', 542 (r' /archive/(\d{4})/$', archive),543 (r' /archive-summary/(\d{4})/$', archive, {'summary': True}),542 (r'^archive/(\d{4})/$', archive), 543 (r'^archive-summary/(\d{4})/$', archive, {'summary': True}), 544 544 ) 545 545 546 546 This is completely valid, but it leads to problems when you try to do reverse … … 557 557 Here's the above example, rewritten to used named URL patterns:: 558 558 559 559 urlpatterns = patterns('', 560 url(r' /archive/(\d{4})/$', archive, name="full-archive"),561 url(r' /archive-summary/(\d{4})/$', archive, {'summary': True}, "arch-summary"),560 url(r'^archive/(\d{4})/$', archive, name="full-archive"), 561 url(r'^archive-summary/(\d{4})/$', archive, {'summary': True}, "arch-summary"), 562 562 ) 563 563 564 564 With these names in place (``full-archive`` and ``arch-summary``), you can