试图在Django上安装PyBB,当试图启动论坛页面出错时,在新安装的虚拟机上做了同样的事情一切正常,在我的Djando上看起来像问题,可能是什么问题?
TemplateSyntaxError at /forum/
Could not parse the remainder: ':pybb_category_add' from 'admin:pybb_category_add'
Request Method: GET
Request URL: http://127.0.0.1:8000/forum/
Django Version: 1.5
Exception Type: TemplateSyntaxError
Exception Value:
Could not parse the remainder: ':pybb_category_add' from 'admin:pybb_category_add'
Exception Location: /usr/local/lib/python2.7/dist-packages/django/template/base.py in __init__, line 570
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/home/denis/hosts/blog',
'/usr/local/lib/python2.7/dist-packages/django_simple_captcha-0.3.5-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages/pytz-2012h-py2.7.egg',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
Error during template rendering
In template /usr/local/lib/python2.7/dist-packages/pybb/templates/pybb/index.html, error at line 17
Could not parse the remainder: ':pybb_category_add' from 'admin:pybb_category_add'
7 {% with extra_crumb="Forum" %}{% include "pybb/breadcrumb.html" %}{% endwith %}
8 {% endblock %}
9
10 {% block content %}
11 {% if categories %}
12 {% for category in categories %}
13 {% include 'pybb/category.html' %}
14 {% endfor %}
15 {% else %}
16 <h2>{% trans "Forum categories are not created" %}</h2>
17 <a href="{% url admin:pybb_category_add %}">{% trans "Add a category now" %}</a>
18 {% endif %}
19 {% if user.is_authenticated %}
20 <div id='mark-all-as-read'>
21 <a href='{% url pybb:mark_all_as_read %}'>
22 {% trans "Mark all forums as read" %}
23 </a>
24 </div>
25 {% endif %}
26 {% endblock content %}
27
答案 0 :(得分:2)
使用{% url %}
标记时尝试使用引号:
<a href="{% url 'admin:pybb_category_add' %}">{% trans "Add a category now" %}</a>%}
...
<a href="{% url 'pybb:mark_all_as_read' %}">
来自文档:
第一个参数是格式化视图函数的路径 package.package.module.function。它可以是引用的文字或任何 其他上下文变量。