TemplateSyntaxError在/帐号/登录/
问题描述:
我想使用这里的例子提供给构建一个简单的Django论坛: http://lightbird.net/dbe/forum1.htmlTemplateSyntaxError在/帐号/登录/
这是我的错误,当我尝试打开本地主机/论坛/
TemplateSyntaxError at /accounts/login/
Could not parse the remainder: ':index' from 'admin:index'
Error during template rendering
In template /Documents/Projects/dbe/forum/templates/forum/fbase.html, error at line 52
Could not parse the remainder: ':index' from 'admin:index'
42
43 <body>
44 <div id="sidebar"> {% block sidebar %} {% endblock %} </div>
45 <div id="container">
46 <div id="menu">
47 {% block nav-global %}
48
49 <!-- MENU -->
50 <h3><a href="{% url forum.views.main %}">ForumApp</a></h3>
51
52 {% if user.is_staff %} <a href="{% url admin:index %}">Admin</a> {% endif %}
53 {% if user.is_authenticated %}
54 <a href="{% url forum.views.profile user.pk %}">Edit profile</a> {% endif %}
55
56 {% if not user.is_authenticated %}<a href="/accounts/login/?next=/forum/">login</a> | <a
57 href="/accounts/register/">register</a>{% endif %}
58
59 {% if user.is_authenticated %}<a href="/accounts/logout/?next=/forum/">logout</a>
60 {% endif %}
61
62 {% endblock %}
答
尝试在URL周围加引号。 更改
"{% url admin:index %}"
到
"{% url 'admin:index' %}"
@Anish帕蒂尔:这是在Django 1.5改变。以前的版本不需要第一个参数的引号,现在他们会这样做。 – mhawke 2015-04-04 11:59:17
感谢编辑@mhawke :) – 2015-04-04 12:00:52