Opened 7 years ago

Closed 7 years ago

#11926 closed (invalid)

URL regular expressions in wrong order

Reported by: ginzor Owned by: nobody
Component: Documentation Version: 1.1
Severity: Keywords: tutorial
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Either I have missed something completely or the following regular expressions are out of order. At least if I turn them around so the more specific turns up at the top the "fall through" and thereby the logic works properly for me. several places

urlpatterns = patterns('',
    (r'^polls/$', 'mysite.polls.views.index'),
    (r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'),
    (r'^polls/(?P<poll_id>\d+)/results/$', 'mysite.polls.views.results'),
    (r'^polls/(?P<poll_id>\d+)/vote/$', ''),

Change History (1)

comment:1 Changed 7 years ago by Luke Plant

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: invalid
Status: newclosed

It does not matter what order they are in, since the '$' at the end matches the end of the string, so there is no need for 'fall through' - "polls/123/", for example, will match only the second pattern.

Note: See TracTickets for help on using tickets.
Back to Top