2015-04-04 76 views
0

我想使用這裏的例子提供給構建一個簡單的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 %} 

回答

4

嘗試在URL周圍加引號。 更改

"{% url admin:index %}" 

"{% url 'admin:index' %}" 
+0

@Anish帕蒂爾:這是在Django 1.5改變。以前的版本不需要第一個參數的引號,現在他們會這樣做。 – mhawke 2015-04-04 11:59:17

+0

感謝編輯@mhawke :) – 2015-04-04 12:00:52