Your regex isn't going to do the job. I'd expect it to look more like:
^site/(?P<path>[-\w]+)/$
to do what you want. Two main differences: URL patterns shouldn't match against a leading slash, ie the slash gets stripped (or, more accurately, isn't part of the path component of a URL, but that's getting pedantic); and ?P
in expressions should take a name for the group (which gets converted into a parameter to your view function).
One other thing you may not be aware of: you have a trailing /
at the end of your URLconf line, but not in the URLs you're trying to match. Note that by default Django (with the CommonMiddleware
running) will auto-redirect to include a trailing /
unless the path already matches something in the URLconf; this can be controlled using the APPEND_SLASH
configuration option. That should "just work" in your case, although it results in a redirect so you shouldn't emit URLs without the trailing slash (or make the slash optional in the URLconf).