文章详情页
python - django模板 include模板的数据问题
浏览:298日期:2022-08-17 17:16:36
问题描述
如:views.py返回是return render(request, ’index.html’)而index.html内容是:
{% include ’header.html’ %}
然后header.html的内容可以是动态的吗?怎么写,谢谢!
{{text}}
问题解答
回答1:header可以是动态的,但是动态的变量需要render时渲染出去.如:
header.html
<script src='https://www.haobala.com/wenda/{{ static_url(’js/common.js’) }}' type='text/javascript' charset='utf-8'></script><p class='header'> {{ user.username }} </p>
index.html
<html><head></head><body> {% include 'header.html' %} <!--包含了header.html的代码--> ...</body></html>
相关文章:
1. Java。比较字符串时忽略重音2. javascript - nodemailer连接超时,怎么解决?3. node.js - 使用mongoose的cursor的问题4. mysql - Access denied for user ’ODBC’@’localhost’ (using password: NO)5. 老师,flex-shrink: 1; 按视频操作,不会自动缩放6. python 匹配数据输出数据7. php study 安装 composer 用不了8. 在别的电脑使用JDBC连接其他电脑上安装的mysql数据库9. PHP中的$this代表当前的类还是方法?10. mysql - 订单表,我把它分成好几个,我要查询订单,怎么用一条sql语句高效查询
排行榜

网公网安备