Opened 15 years ago

Closed 15 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: no UI/UX: no

Description

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.

http://docs.djangoproject.com/en/dev/intro/tutorial03/ 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/$', 'mysite.polls.views.vote'),
)

Change History (1)

comment:1 by Luke Plant, 15 years ago

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