久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

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

瀏覽:149日期: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://m.baoyu77737.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 編程
相關(guān)文章:
主站蜘蛛池模板: 临邑县| 漳平市| 泰来县| 五常市| 公安县| 长春市| 万载县| 丹棱县| 吴忠市| 眉山市| 沙田区| 内江市| 克什克腾旗| 桐庐县| 融水| 三门县| 怀柔区| 宜兴市| 华容县| 昭通市| 鄂州市| 谷城县| 宜章县| 博爱县| 泸州市| 华坪县| 慈利县| 新密市| 巢湖市| 乌拉特中旗| 甘孜| 房山区| 彭山县| 五常市| 奉节县| 和顺县| 宜宾市| 五原县| 雷波县| 金平| 蒙城县|