开发者

Django dynamic url. what am i doing wrong?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜