本次blog系统的全端使用了django模板,而不是jinjia2。

为了让整个网站系统具有整齐的布局,同时页面的各个部分具有可复用性。一般从如下几点考虑:

1、将index页面拆分几块。各个页面都继承自base。可变部分可以定义在block中,公用模板可以使用include

Blog_Django(五):blog的页面布局:模板、过滤器

2、base的布局如下:

{% load staticfiles %}
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{ site_name }}</title>
    <meta name="keywords" content="{{ site_name }}"/>
    <meta name="description" content="{{ site_desc }}"/>
    <link href='{% static "base/css/base.css" %}' rel="stylesheet">
    <link href='{% static "base/css/index.css" %}' rel="stylesheet">
    {% block customer_css %}{% endblock %}
    <script type="text/javascript" src='{% static "jquery/jquery-3.1.1.js" %}'></script>
    <script type="text/javascript" src='{% static "base/js/sliders.js" %}'></script>
    {% block customer_js %}{% endblock %}
</head>
<body>
<header>
    {% include "main/header.html" %}
</header>
<article>
    <div class="l_box f_l">
        {% include "main/ad.html" %}
        <!-- banner代码 结束 -->
        {% block content %}{% endblock %}
    </div>
    {% include "main/right.html" %}
</article>
<footer>
    {% include "main/footer.html" %}
</footer>
</body>
</html>
base.html

相关文章:

  • 2021-08-06
  • 2021-09-17
  • 2021-12-05
  • 2021-10-31
  • 2021-11-13
  • 2021-09-14
猜你喜欢
  • 2021-11-30
  • 2021-12-04
  • 2019-02-22
  • 2020-02-12
  • 2021-05-24
  • 2019-09-18
  • 2021-11-05
  • 2021-12-09
相关资源
相似解决方案