base.html
{% load static %}
<!DOCTYPE html>
< html lang = " en" >
< head>
< meta charset = " UTF-8" >
< title> base</ title>
< link rel = " stylesheet" type = " text/css" href = " {% static ' dist/css/bootstrap.css' %}" />
< script src = " {% static ' jquery-3.4.1.js' %}" type = " text/javascript" charset = " utf-8" > </ script>
< script src = " {% static ' dist/js/bootstrap.js' %}" type = " text/javascript" charset = " utf-8" > </ script>
</ head>
< body>
< div class = " container" >
< div>
头部
{% include 'header.html' %}
</ div>
< div>
中间内容
{% block main %}
{% endblock %}
</ div>
< div>
尾部
{% include 'footer.html' %}
</ div>
</ div>
</ body>
</ html>
header.html
< nav class = " navbar navbar-default" role = " navigation" >
< div class = " container-fluid" >
< div class = " navbar-header" >
< a class = " navbar-brand" href = " #" > header</ a>
</ div>
< ul class = " nav navbar-nav navbar-right" >
{% for m in menu %}
< li> < a href = " #" > {{ m.mname }}</ a> </ li>
{% endfor %}
</ ul>
</ div>
</ nav>
footer.html
< ul class = " pagination" >
< li> < a href = " #" > « </ a> </ li>
< li> < a href = " #" > 1</ a> </ li>
< li> < a href = " #" > 2</ a> </ li>
< li> < a href = " #" > 3</ a> </ li>
< li> < a href = " #" > 4</ a> </ li>
< li> < a href = " #" > 5</ a> </ li>
< li> < a href = " #" > » </ a> </ li>
</ ul>
query.html
{% extends 'base.html' %}
{% block main %}
这是主题内容,写什么由我决定!
{% endblock %}