Code

Opened 5 years ago

Closed 5 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:

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'),
)

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by lukeplant

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.