0

I have the following url:

http://mysite.com/config/1:1/

This gives me a 404 page not found.

If I try this: it find my url entry no problem. http://mysite.com/config/1/

This what my url pattern looks like:

 url(r'^config/(?P<config_id>\d+)/$', views.config, name='config'),

Is there a problem with having the colon in the url?

4

1 回答 1

2

您的正则表达式只允许数字。 \d不匹配:。如果您的视图函数能够处理冒号,请扩大模式:

url(r'^config/(?P<config_id>[\d:]+)/$', views.config, name='config')

由于您已经命名了模式config_id,我怀疑它是主键,这不适用于视图,但这取决于视图本身。

于 2013-07-30T23:51:57.243 回答