其實(shí)就是利用{% block xxx %} {% endblock %}的方式定義一個(gè)塊,相當(dāng)于占位。存放在某個(gè)html中,比如base.html
創(chuàng)新互聯(lián)2013年至今,是專(zhuān)業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站建設(shè)、網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元余杭做網(wǎng)站,已為上家服務(wù),為余杭各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792然后在需要實(shí)現(xiàn)這些塊的文件中,使用繼承{% extends "base.html" %}的方式引入母板文件,然后在{% block xxx %}......{% endblock %}塊定義中實(shí)現(xiàn)具體的內(nèi)容。
base.html示例:注意塊的定義。
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 上述3個(gè)meta標(biāo)簽*必須*放在最前面,任何其他內(nèi)容都*必須*跟隨其后! --> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" rel="external nofollow" > <link rel="stylesheet" rel="external nofollow" > <title>所有的書(shū)都在這里</title> {% block page_css %} {% endblock %} {% block page_js %} {% endblock %} <!-- Bootstrap core CSS --> <link rel="external nofollow" rel="stylesheet"> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <link rel="external nofollow" rel="stylesheet"> <!-- Custom styles for this template --> <link rel="external nofollow" rel="stylesheet"> <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> <!--[if lt IE 9]><script src="http://v3.bootcss.com/assets/js/ie8-responsive-file-warning.js"></script><![endif]--> <script src="http://v3.bootcss.com/assets/js/ie-emulation-modes-warning.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> {% include "nav.html" %} <div class="container-fluid"> <div class="row"> <div class="col-sm-3 col-md-2 sidebar"> <ul class="nav nav-sidebar"> <li class="{% block book_class %}{% endblock %}"><a href="/book_list/" rel="external nofollow" >所有的書(shū) <span class="sr-only">(current)</span></a> </li> <li class="{% block publisher_class %}{% endblock %}"><a href="/publisher_list/" rel="external nofollow" >出版社</a></li> <li class="{% block author_class %}{% endblock %}"><a href="/author_list/" rel="external nofollow" >作者</a></li> </ul> </div> <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> {% block main_body %} {#這里是每個(gè)頁(yè)面不同的部分#} {% endblock %} </div> </div> </div> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="http://v3.bootcss.com/assets/js/vendor/jquery.min.js"><\/script>')</script> <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <!-- Just to make our placeholder images work. Don't actually copy the next line! --> <script src="http://v3.bootcss.com/assets/js/vendor/holder.min.js"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script src="http://v3.bootcss.com/assets/js/ie10-viewport-bug-workaround.js"></script> </body> </html>
網(wǎng)頁(yè)標(biāo)題:python之django母板頁(yè)面的使用-創(chuàng)新互聯(lián)
URL地址:http://aaarwkj.com/article4/hssie.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、ChatGPT、網(wǎng)站設(shè)計(jì)公司、響應(yīng)式網(wǎng)站、自適應(yīng)網(wǎng)站、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容