1. Luke Plant
  2. django


mtre...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed 40e53b1

[1.0.X] Fixed #9472 -- Fixed a couple of URL patterns to be more consistent (and remove a misleading initial slash). Thanks, daveyjoe.

Backport of r9471 from trunk.

  • Participants
  • Parent commits a40ebe2
  • Branches releases/1.0.X

Comments (0)

Files changed (1)

File docs/topics/http/urls.txt

View file
 optional extra arguments dictionary. For example::
     urlpatterns = patterns('',
-        url(r'/index/$', index_view, name="main-view"),
+        url(r'^index/$', index_view, name="main-view"),
     urlpatterns = patterns('',
-        (r'/archive/(\d{4})/$', archive),
-        (r'/archive-summary/(\d{4})/$', archive, {'summary': True}),
+        (r'^archive/(\d{4})/$', archive),
+        (r'^archive-summary/(\d{4})/$', archive, {'summary': True}),
 This is completely valid, but it leads to problems when you try to do reverse
 Here's the above example, rewritten to use named URL patterns::
     urlpatterns = patterns('',
-        url(r'/archive/(\d{4})/$', archive, name="full-archive"),
-        url(r'/archive-summary/(\d{4})/$', archive, {'summary': True}, "arch-summary"),
+        url(r'^archive/(\d{4})/$', archive, name="full-archive"),
+        url(r'^archive-summary/(\d{4})/$', archive, {'summary': True}, "arch-summary"),
 With these names in place (``full-archive`` and ``arch-summary``), you can