可以将常用的页面内容如导航条,页尾信息等组件保存在单独的文件中的一个小功能块,然后在需要使用的地方,文件的任意位置按如下语法导入即可。

模板组件:

新建一个组件zujian.html文件(一个固定写好的静态页面)

在新的html文件中需要引入的位置加上include标签:{% include "zujian.html" %}

模板组件引用演示:

zujian.html

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
.c1, .nav {margin: 0 auto;width: 1200px;background-color: #d6d6d6;color: white;}
.navleft {float: left;text-align: left;}
.navright {float: right;}
.fixed:after {content: "";display: block;clear: both;}
ul, li {list-style: none;display: inline;margin: 0;padding: 0;}
</style>
<title>模板组件</title>
</head>
<body>
<div class="c1">
<div class="nav fixed">
<div class="navleft ">
<ul>
<li>古诗</li>
<li>绝句</li>
<li>诗经</li>
</ul>
</div>
<div class="navright">
<ul>
<li>登录</li>
<li>注册</li>
</ul>
</div>
</div>
</div> </body>
</html>

 zujian_demo.html  

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>模板组件引入演示</title>
</head>
<body>
<div> {% include "zujian.html" %}</div>
<div><h1>模板组件引入演示(include标签可以放在任意位置)</h1></div>
<div> {% include "zujian.html" %}</div>
</body>
</html>

  views.py

 def zujian(request):
return render(request,"zujian.html")
def zujian_demo(request):
return render(request,"zujian_demo.html")

  结果演示:

    

最新文章

  1. oracle pl/sql split函数
  2. Python asyncio库的学习和使用
  3. Response.Redirect引起的“无法在发送HTTP标头之后进行重定向”
  4. MS SQL SERVER 数据库日志压缩方法与代码
  5. Regarding the %EDIT table
  6. BAT及各大互联网公司2014前端笔试面试题:HTML/CSS篇
  7. visual studio 辅助工具
  8. 基于MongoDB打造.Net的分布式Session子系统
  9. pro文件常用内容
  10. 汽车之家店铺商品详情数据抓取 DotnetSpider实战[二]
  11. cnzz流量统计
  12. springboot~application.properties和application.yml的使用
  13. 【Wyn Enterprise BI知识库】 认识多维数据建模与分析 ZT
  14. MySQL复制ERROR 1794 (HY000): Slave is not configured or failed to initialize properly.
  15. 微服务的发现与注册--Eureka
  16. SKU与SPU
  17. 20165310java_teamExp1_week1
  18. dp练习(11)——石子并归
  19. ntp服务的细节全解析
  20. 26.OGNL与ValueStack(VS)-N语法top语法

热门文章

  1. php函数封装
  2. unset变量释放内存不起作用
  3. curl请求curl_exec返回false,curl_error返回空
  4. PHP中级篇 Apache配置httpd-vhosts虚拟主机总结及注意事项
  5. Nmap详细用法
  6. Python学习17之类3继承
  7. How to check if directory exist using C++ and winAPI
  8. Scala教程之:可变和不变集合
  9. 日日算法:Kruskal算法
  10. 我想solo自己一个人!