6

我在stackoverflow链接中应用了修复:

<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 %},没关系。


这很奇怪。

4

1 回答 1

12

尝试加上shop_index引号:

<a href="{% url 'shop_index' %}">

没有引号,shop_index将被视为模板变量而不是字符串。

于 2012-07-08T13:51:43.633 回答