文章詳情頁
python - django模板 include模板的數據問題
瀏覽:143日期: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='http://m.lshqa.cn/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 - 移動端padding問題2. javascript - ios上fixed定位問題,定位在底部的按鈕不顯示了,但是又可以點擊到,換了一個類名就可以顯示了,但是設置的字體大小卻失效了3. javascript - js正則替換日期格式問題4. javascript - 關于微信掃一掃的技術問題5. javascript - Vue.js的ElementUI庫中,如何主動觸發checkbox組件的change事件?6. javascript - webpack 打包 reactjs項目 css 分離7. javascript - vuex中子組件無法調用公共狀態8. javascript - 請教移動端從詳情頁返回到列表頁原來位置的問題?9. javascript - (_a = [""], _a.raw = [""],....); js一個小括號的是什么意思?10. javascript - 怎樣定位一個動作調用了哪個js,不打斷點調試?
排行榜
