Template Inheritance Example
1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>{% block title%} {% Endblock%}</title>6 <Linkrel= "stylesheet"href= "/static/commons.css" />7 <style>8 . Pg-header{9 Height:50px;Ten Background-color:Seashell; One Color:Green; A } - </style> - {% block css%} {% Endblock%} the </Head> - <Body> - <Divclass= "Pg-header">Little Boy Management</Div> - <Div> + <a>Asdf</a> - <aID="">Asdf</a> + <a>Asdf</a> A <a>Asdf</a> at <a>Asdf</a> - </Div> - <iframesrc="/"></iframe> - </Body> - </HTML>
Inherited
1 {% extends ' master.html '%} #继承master. html, only one template can be inherited2 3 {% block title%} User management {% Endblock%}4 5 {% block content%}6 <H1>User Management</H1>7 <ul>8 {% for I in u%}9 <Li>{{i}}</Li>Ten {% endfor%} One </ul> A - {% for I in u%} - {% include ' tag.html '%} #include导入一个模板, you can import multiple the {% endfor%} - - {% Endblock%} - + {% block css%} - <style> + Body{ A Background-color:Red; at } - </style> - {% Endblock%} - - {% block js%} - <Script></Script> in{% Endblock%}
The inheritance of Django's master version