Ticket #9472: urls.txt.diff

File urls.txt.diff, 1.2 KB (added by daveyjoe, 16 years ago)
  • (a) urls.txt vs. (b) (current

    a b  
    227227optional extra arguments dictionary. For example::
    228228
    229229    urlpatterns = patterns('',
    230         url(r'/index/$', index_view, name="main-view"),
     230        url(r'^index/$', index_view, name="main-view"),
    231231        ...
    232232    )
    233233
     
    539539view::
    540540
    541541    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}),
    544544    )
    545545
    546546This is completely valid, but it leads to problems when you try to do reverse
     
    557557Here's the above example, rewritten to used named URL patterns::
    558558
    559559    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"),
    562562    )
    563563
    564564With these names in place (``full-archive`` and ``arch-summary``), you can
Back to Top