Bur*_*rak 6 django django-templates django-urls
我在stackoverflow 链接中应用了修复程序:
<a href="{% url shop_index %}"><span>{% trans "Shop List" %}</span></a>
Run Code Online (Sandbox Code Playgroud)
在urls.py:
url(r'^shop/$', 'index', name="shop_index"),
Run Code Online (Sandbox Code Playgroud)
但仍然是同样的错误.我哪里错了?
更新:
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 %},没关系.
这很奇怪.
Tim*_*ony 12
尝试shop_index加入引号:
<a href="{% url 'shop_index' %}">
Run Code Online (Sandbox Code Playgroud)
如果没有引号,shop_index将被视为模板变量而不是字符串.
| 归档时间: |
|
| 查看次数: |
7239 次 |
| 最近记录: |