文章详情页
python - django模板 include模板的数据问题
浏览:319日期: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. javascript - 百度坐标,返回目标附近有哪些坐标2. javascript - 关于jsp中嵌入js代码的问题3. javascript - 有什么兼容性比较好的办法来判断浏览器窗口的类型?4. javascript - 一个JS多元运算符的问题5. javascript - html5多个label中其中一个触发change,如何判断是哪一个出发了change6. javascript - 判断用户网络环境7. clone - git sourceTree克隆仓库时,都不停弹出Password Required弹窗,即时输入正确的git账号密码还是弹出8. python - 怎么通过vpn连内网ftp?9. angular.js - angurlarJS的安卓的微信端中用加载ngCookies会出错的问题10. python 正则表达式提取
排行榜

网公网安备