Ticket #4817: 4817.patch

File 4817.patch, 1.3 KB (added by Collin Grady <cgrady@…>, 12 years ago)
  • docs/url_dispatch.txt

     
    200200optional extra arguments dictionary. For example::
    201201
    202202    urlpatterns = patterns('',
    203         url(r'/index/$', index_view, name="main-view"),
     203        url(r'index/$', index_view, name="main-view"),
    204204        ...
    205205    )
    206206
     
    506506view::
    507507
    508508    urlpatterns = patterns('',
    509         (r'/archive/(\d{4})/$', archive),
    510         (r'/archive-summary/(\d{4})/$', archive, {'summary': True}),
     509        (r'archive/(\d{4})/$', archive),
     510        (r'archive-summary/(\d{4})/$', archive, {'summary': True}),
    511511    )
    512512
    513513This is completely valid, but it leads to problems when you try to do reverse
     
    524524Here's the above example, rewritten to used named URL patterns::
    525525
    526526    urlpatterns = patterns('',
    527         url(r'/archive/(\d{4})/$', archive, name="full-archive"),
    528         url(r'/archive-summary/(\d{4})/$', archive, {'summary': True}, "arch-summary"),
     527        url(r'archive/(\d{4})/$', archive, name="full-archive"),
     528        url(r'archive-summary/(\d{4})/$', archive, {'summary': True}, "arch-summary"),
    529529    )
    530530
    531531With these names in place (``full-archive`` and ``arch-summary``), you can
Back to Top