Django URL模式-字符串参数 [英] Django url pattern - string parameter
本文介绍了Django URL模式-字符串参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
具有数字参数的Django网址格式为:
Django url pattern that have a number parameter is:
url(r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail')
什么是正确的
What will be the correct syntax if my poll_id is not a number but a string of character?
推荐答案
取决于您所关心的字符。就像文档所说的那样, \w
将为您提供字母数字字符或下划线。
Depends on what characters you care about. Like the docs say, \w
will give you an alphanumeric character or an underscore.
这篇关于Django URL模式-字符串参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文