python - 无效的 block 标记 : 'bootstrap_icon' , 预期 'endblock'

标签 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 %}

但是我得到了

Invalid block tag: 'bootstrap_icon', expected 'endblock'

错误。

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

在 base.html 文件中。

最佳答案

您应该在模板中加载 {% 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 %}

关于python - 无效的 block 标记 : 'bootstrap_icon' , 预期 'endblock',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28590149/

相关文章:

python - Scikit 学习,Numpy : Changing the value of an read-only variable

python - 用多列交换或交换 pandas 数据框中的列名

python - 无法从 for 循环中的列表中提取字典

python - 对数据帧中的列执行 str.split 会返回SettingWithCopyWarning

python - 使用scrapy从脚本标签中提取数据

python - "TypeError: ' null 第一次执行代码时为' is not an object"

python - 是否可以对使用子进程的代码运行单元测试?

python - 导入错误 : cannot import name NullHandler

python - 上传在 Github 上的虚拟环境中设置的 Django 项目

python : Remove duplicate elements in lists and sublists; and remove full sublist if duplicate