开发者

URL regex in django with limited set of words

开发者 https://www.devze.com 2022-12-15 20:41 出处:网络
Given the following djang开发者_开发技巧o URL conf. entry: url(r\'^(?P<obj_ctype_name>\\w+)/(?P<obj_id>\\d+)/$\',

Given the following djang开发者_开发技巧o URL conf. entry:

url(r'^(?P<obj_ctype_name>\w+)/(?P<obj_id>\d+)/$',
    views.obj_view,
    name='obj_view')

How would I rewrite the parameter (?P<obj_ctype_name>\w+) to enforce that it may only be one of "foo" "bar" or "baz" and still keep it as a named parameter?


(?P<obj_ctype_name>foo|bar|baz)

0

精彩评论

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

关注公众号