baker95935

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

看到了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的代码不在提供了,都是静态的内容

posted on 2018-06-11 15:20  baker95935  阅读(251)  评论(0编辑  收藏  举报