我正在尝试使用此处提供的示例构建一个简单的django论坛: http://lightbird.net/dbe/forum1.html
当我尝试打开localhost / forum /
时,这是我得到的错误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 %}
答案 0 :(得分:4)
尝试在网址周围加上引号。 改变
"{% url admin:index %}"
到
"{% url 'admin:index' %}"