Raise 404 and continue the URL chain

Viewed 41106

I've got a URLs pattern like this:

urlpatterns = (
    url(r'^$', list_titles, name='list'),
    url(r'^(?P<tag>[a-z\-0-9]+?)/$', list_titles, name='filtered-list'),
    url(r'^(?P<title>\S+?)/$', show_title, name='title'),
)

The filtered-list and title match the same things.

If there is an available list of things matching the tag in filtered-list, I want list_titles to fire off. But if there isn't a matching tag, I want to bubble that back to the URL processor so show_title fires off.

If there's no matching title, I'll raise a proper 404 there.

I know I can do this from inside the view...but it's a bit smelly having to hard-wire the process into the view. I'd like the URL order to decide what gets chosen first and what it hands off to.

1 Answers
Related