无效的块标记:'bootstrap_icon',预期'endblock'

时间:2015-02-18 17:37:52

标签: python django python-2.7

我正在尝试在我的项目中使用django-bootstrap3包。

我已经构建了这样的模板:

{% extends "base.html" %}

{% block content %}

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">{% bootstrap_icon "star" %} All customers</h3>
    </div>
    <div class="panel-body">
        All your customers are listed here in alphabetical order. In this panel you can update and delete
        your customer informations.
    </div>
</div>
    {{ customers }}

{% endblock %}

但我得到了

  

无效的块标记:'bootstrap_icon',预期'endblock'

错误。

{% load bootstrap3 %}
{% bootstrap_css %}
{% bootstrap_javascript %}

是否在base.html文件中。

1 个答案:

答案 0 :(得分:13)

您应该在模板中加载{% load bootstrap3 %}

{% extends "base.html" %}
{% load bootstrap3 %}


{% block content %}

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">{% bootstrap_icon "star" %} All customers</h3>
    </div>
    <div class="panel-body">
        All your customers are listed here in alphabetical order. In this panel you can update and delete
        your customer informations.
    </div>
</div>
    {{ customers }}

{% endblock %}