开发者

Django dynamic url. what am i doing wrong?

开发者 https://www.devze.com 2023-02-10 14:59 出处:网络
So I have this URL scheme: (r\'^test/(?P<name>\\d+开发者_如何转开发)/\', \'test\'), def test(request, name):

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

精彩评论

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