我在模板中有这个链接:
<a href="{% url show_item item.id %}">Item 1</a>
以及 urls.py 中的这个 url
url(r'item/(?P<id>)/$', show_item, name="page_item")
但是,出现此错误:
Reverse for 'show_item' with arguments '(63L,)' and keyword arguments '{}' not found.
我看了这个问题:
如何让 python 不将 L 附加到 long 或在 django 模板中忽略 https://stackoverflow.com/questions/9404142/how-to-get-python-to-not-append-l-to-longs-or-ignore-in-django-template?rq=1
但这没有帮助。
在模板中构造 URL 时,是否有另一种方法可以使用主键(整数)?
URL 名称不匹配。将模板更改为:
<a href="{% url page_item item.id %}">Item 1</a>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)