7
7
7761662019-05-22 11:45:54
Django
776166, 2019-05-22 11:45:54

What's wrong with URL dispatcher?

You need to process two urls. One of them is a more special case of the first.
In theory, it is necessary to put a more general case after the particular one, which will be processed first. But that doesn't happen. And I still don’t understand how to use negation in the url regular expression.

# Частный случай
url(r'^serial/(?P<serial_id>[\d]+)/s(?P<season_number>[\d]+)/$', video.season_view),

# Общий случай
url(r'^(?P<level0>([\w\d_-]+))/(?P<level1>([\w\d_-]+))/(?P<level2>[\w\d_-]+)/$', category.level3),

/serial/10/s12/should handle a special case
/foo/bar/baz/- a general one.
But the general intercepts the first url.
Questions:
1) What is wrong? Why doesn't order work?
2) Is it possible for the general case to prohibit the interception of /serial/ separately with a regular expression? How?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question