django之模板继承

By 肖奈
2017-09-29
2408 read

 在web开发中,很多时候都会引入公用的头部和尾部,下面我记录一下在django模板中引入公用头部和尾部的例子,新手,请勿狂喷,有写的不对的地方,请帮忙指出,谢谢


1、首先建立公用模板文件,贴一下我的html模板

#vim base.html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Jeff的博客</title>
    </head>
    <body>
    {% block content %}
    {% endblock %}
    </body>
    </html>

2、在其他文件中引入base.html

    {% extends 'base.html' %}
    {% block content %}
    <h1>test</h1>
    {% endblock %}


Django提交表单出错”django, CSRF token missing or incorrect”
python 字典、列表、json转换

Comments

暂无评论,还不快来坐沙发...

Leave a Reply