【发布时间】:2017-09-20 09:05:31
【问题描述】:
我可以访问 URL 中的username1/edit,但无法通过单击模板中的链接来访问。
urls.py
url(r'^(?P<slug>[-\w\d]+)/edit/$', ProfileEdit.as_view(), name='profile_edit'),
template.html
<a href="{% url 'profile:profile_edit' %}">edit</a>
我收到以下错误
未找到带有参数“()”和关键字参数“{}”的“profile_edit”的反向操作。尝试了 1 种模式:['(?P[-\w\d]+)/edit/$']
我得到的问题是没有将 slug 值发送到 url。但是如何从模板发送 slug 值?
【问题讨论】:
-
如错误所示,您没有将 slug 传递给 url 标签。
-
我明白了!我该如何克服这个错误?
标签: python django django-templates