文章詳情頁
python - django模板 include模板的數(shù)據(jù)問題
瀏覽:161日期:2022-08-17 17:16:36
問題描述
如:views.py返回是return render(request, ’index.html’)而index.html內(nèi)容是:
{% include ’header.html’ %}
然后header.html的內(nèi)容可以是動態(tài)的嗎?怎么寫,謝謝!
{{text}}
問題解答
回答1:header可以是動態(tài)的,但是動態(tài)的變量需要render時渲染出去.如:
header.html
<script src='http://www.intensediesel.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>
相關(guān)文章:
1. 管理員信息修改時的密碼問題2. html5 - 為什么使使用vue cli 腳手架,post-css 沒有自動對css3屬性自動添加瀏覽器前綴呢?3. angular.js - 輸入郵箱地址之后, 如何使其自動在末尾添加分號?4. android - RxJava 中有根據(jù)條件執(zhí)行不同函數(shù)的操作符嗎?5. javascript - 如何使用nodejs 將.html 文件轉(zhuǎn)化成canvas6. java如何生成token?7. javascript - 后臺管理系統(tǒng)左側(cè)折疊導(dǎo)航欄數(shù)據(jù)較多,怎么樣直接通過搜索去定位到具體某一個菜單項位置,并展開當(dāng)前菜單8. javascript - html5的data屬性怎么指定一個function函數(shù)呢?9. 如何解決docker宿主機無法訪問容器中的服務(wù)?10. mysql - 電商如何存儲營業(yè)額數(shù)據(jù)
排行榜

熱門標(biāo)簽