Django:无效的块标记:' score_for_object',预期'空' o' endfor'

时间:2014-07-08 11:53:13

标签: python django django-voting

我正在尝试新的django,即时通讯使用django 1.6。我正在尝试使用django-voting,如教程中所述:http://www.justinlilly.com/python/django_voting.html

我在申请模板时收到错误消息:

无效的块标记:' score_for_object',预期'空' o' endfor'

我的模板如下:

{% score_for_object object as score %}
                <h5>Votes <span id="score">{{ score.score }}</span> point{{ score.score|pluralize }}
                     after <span id="num_votes">{{ score.num_votes }}</span> vote{{ score.num_votes|pluralize }}</h5>
            <ul>
                <li><a href="#" onclick="vote('{{ object.slug }}', 'up');">I like it!</a></li>
                <li><a href="#" onclick="vote('{{ object.slug }}', 'down');">I hate it!</a></li>
                <li><a href="#" onclick="vote('{{ object.slug }}', 'clear');">I take it back! Clear my vote.</a></li>
            </ul>
                {% endscore_for_object object %}

我试过没有{%endscore_for_object对象%}并且我收到了相同的错误消息 我的网址:

tip_dict = {
    'model': Promo,
    'template_object_name': 'promos',
    'slug_field': 'slug',
    'allow_xmlhttprequest': 'true',
}
urlpatterns += patterns('',
   url(r'^(?P<object_id>\d+)/(?P<direction>up|down|clear)vote/?$', vote_on_object,             tip_dict, name="tip-voting"),
)

提前致谢!

1 个答案:

答案 0 :(得分:3)

我认为您需要加载模板标记,例如

{% load voting_tags %} 

在html文件的开头,请参阅:Django docdjango-voting doc