定义母版---new.html
html
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<div>
{% block contents %}
{% endblock %}
</div>
</body>
</html>
继承母模板
html
{% extends 'new.html' %}
{% block contents %}
<h1>首页</h1>
{% endblock %}
注:{% block contents %} 中,是自由定义的,只要和子模板里面相对应即可。