2

So I have this URL scheme:

(r'^test/(?P<name>\d+)/', 'test'),

def test(request, name):
    html = "it worked"
    return HttpResponse(html)

however, when I go to the following URL, I get a 404 error: http://127.0.0.1:8000/test/words/

What am I doing wrong?

Zac Altman
  • 1,215
  • 4
  • 25
  • 37

1 Answers1

4

You probably meant to use \w instead, e.g.:

(r'^test/(?P<name>\w+)/', 'test'),

\d matches only digits; \w matches any alphanumeric character.

Python Regular Expression HOWTO by A.M. Kuchling.

mechanical_meat
  • 163,903
  • 24
  • 228
  • 223