thefekete.net

$> :(){ :|:& };:

Slug urlconf regex pattern for Django urlpatterns

If you want to match a slug in your urls.py, use (?P[-\w]+) as a named match pattern:

So, if you wanted to match http://example.com/some-slug-name/, you would use

urlpatterns = patterns('',
    # ...
    url(r'^(?P<slug>[-\w]+)/$', some_view),
    # ...
)

I got this info from a Django Users Thread on google groups.

Leave a Reply

HTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting