【问题标题】:No content visible in django-bootstrap3在 django-bootstrap3 中看不到任何内容
【发布时间】:2025-12-22 23:25:15
【问题描述】:

我正在使用 Django 1.9 和演示模板结构来显示 home.html。 我在 base.html 文件中包含以下内容:

{% block bootstrap3_content %}
  <nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
    ...
    </div>
  </nav>
  <div class="container-fluid">
  {% autoescape off %}{% bootstrap_messages %}{% endautoescape %}
  {% block content %}(no content){% endblock %}
  </div>
{% endblock %}

导航栏显示成功,但我没有在下面的容器中收到引导消息? 我是 Django 和这个应用程序的新用户。请帮忙!

编辑1:

bootstrap.html 扩展 bootstrap3.html; base.html 扩展 bootstrap.html; home.html 扩展 base.html。 主页.html

{% block title %}My_title{% endblock %} 
{% block content %} This is <em>bootstrap3</em> for <strong>Django</strong>. 
{% endblock %} 

我在导航栏中得到标题,但content 块内没有消息。

【问题讨论】:

    标签: django twitter-bootstrap-3 django-templates


    【解决方案1】:

    确保你有

    {% load bootstrap3 %}
    

    由于您正在使用此模块,因此位于页面顶部。确保你有

    'bootstrap3',
    

    在您安装的应用程序中。

    从您的代码看来,您正在扩展一个模板。如果你是,一定要有一个

    {% extends FooTemplate.html %}
    

    如果您在父模板中加载 boostrap3。

    【讨论】:

    • 我在基本模板文件中有 {% load bootstrap3 %}。在 INSTALLED_APPS 列表中有“bootstrap3”。
    最近更新 更多