In my Django urlconf, i'd like to return a 404 for requests probing for scripts. Otherwise, the request is needlessly hitting the database to look for a corresponding FlatPage, since i'm using the FlatPage middleware.
My problem is that the following pattern, which matches correctly, is sending 'php', 'cgi', or 'pl' as the template_name
argument to the page_not_found
view function.
urlpatterns = patterns('',
# don't even bother looking up a flatpage for these matches
(r'\.(php|cgi|pl)$', 'django.views.defaults.page_not_found'),
...
)
What is a way to do that regex "or" logic without sending the match as a parameter to the view?
Non-capturing groups are indicated with (?:...)
.