URL配置错误Django

时间:2013-04-19 07:53:14

标签: python django urlconf

我有一个链接

 a href="editYou/{{costumer.slug}}"

和网址格式

(r'editYou/<?P(costumerSlug>.*)/$', 'editYou'),

指向方法

def editYou(request, costumerSlug):

但是Django显示错误:

The current URL, profile/editYou/es, didn't match any of these.

您如何帮我找到原因?

2 个答案:

答案 0 :(得分:5)

你的模式错了,它应该是

r'editYou/(?P<costumerSlug>.*)/$'
#         ^^^^
#   not   <?P(costumerSlug>.*)

答案 1 :(得分:2)

将您的网址命名为:

可能更好
(r'editYou/(?P<costumerSlug>.*)/$', 'editYou', name="edit"),

然后在您的模板中,您可以使用:

 a href="{% url edit costumer.slug %}"
相关问题