成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術文章
文章詳情頁

python - django模板 include模板的數(shù)據(jù)問題

瀏覽:142日期: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.piao2010.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>

標簽: Python 編程
相關文章: