我在stackoverflow link中应用了修复程序:
<a href="{% url shop_index %}"><span>{% trans "Shop List" %}</span></a>
在
urls.py
中:url(r'^shop/$', 'index', name="shop_index"),
但是还是一样的错误。我哪里错了?
更新:
Django
1.5
Python
2.7.2
{% url shop_index %}
给出错误。如果我使用{% url 'shop_index' %}
,那就可以了。Django
1.5.dev17865
Python
2.7.3
{% url 'shop_index' %}
给出错误。如果我使用{% url shop_index %}
,那就可以了。这很奇怪。
最佳答案
尝试将shop_index
放在引号中:
<a href="{% url 'shop_index' %}">
如果不使用引号,则
shop_index
将被视为模板变量而不是字符串。
关于django - “Reverse for ' ' with arguments '()' and keyword arguments ' {} ' not found. ”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11383534/