django2.0模板相关设置

看到了django的模板有include标签

include 标签
{% include %} 标签允许在模板中包含其它的模板的内容。

下面这个例子都包含了 nav.html 模板:
{% include "nav.html" %}

然后就把页面给优化了一下

header.html

footer.html

然后index.html的代码如下

{% include "header.html" %}

    <div class="container" style="margin-top: 50px;">

      <div class="starter-template">

        {% for blog in blog_list %}
            <h2>{{ blog.title }}</h2>
            <p>{{ blog.timestamp }}</p>
            <p>{{ blog.body }}</p>
        {% endfor %}

      </div>

    </div><!-- /.container -->

 {% include "footer.html" %}

header.html和footer.html的代码不在提供了,都是静态的内容

原文地址:https://www.cnblogs.com/baker95935/p/9167221.html