django將數(shù)組傳遞給前臺模板的方法
將數(shù)組傳遞給前臺模板:
1.
def modifyBtn(req,modifyip):
print modifyip
conn= MySQLdb.connect(
host='localhost',
port = 3306,
user='root',
passwd='1234567',
db ='DEVOPS'
)
cur = conn.cursor()
a = cur.execute("select ip,info,env from machine_info where ip=%s ",[modifyip])
info = cur.fetchall()
print info
print type(info)
return render(req,'cmdb/modifyBtn.html',{'info':info})
2. node2:/django/mysite/news/templates/cmdb#cat modifyBtn.html
<html>
<head>
<title>運維平臺</title>
<link rel="stylesheet" type="text/css" href="/static/Css/Equipment/modifyBtn.css" rel="external nofollow" >
<link rel="stylesheet" type="text/css" href="/static/Css/Public/header.css" rel="external nofollow" >
<link rel="stylesheet" type="text/css" href="/static/Css/Public/menu.css" rel="external nofollow" >
</head>
<body>
<include file="Public:header"/>
<div class="content">
<include file="Public:menu"/>
<div class="con fl">
<form id="condition" action="/static/modifyEquipment" method="post">
{% for x in info %}
<label class="condition">地址</label><input type="text" name="ip" class="equipment_sz" value={{x.0}}>
<label class="condition">描述</label><input type="text" name="info" class="equipment_sz" value={{x.1}}>
<label class="condition">環(huán)境</label><input type="text" name="env" class="equipment_sz" value={{x.2}}>
<input type="submit" value="設(shè)備修改" class="equipment_add_btn">
{% endfor %}
</form>
</div>
</div>
</body>
<script type="text/javascript" src="/static/Js/jquery-2.2.2.min.js"></script>
<!-- <script type="text/javascript" src="/static/Js/Equipment/addEquipment.js"></script> -->
</html>
以上這篇django將數(shù)組傳遞給前臺模板的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Python?裝飾器常用的創(chuàng)建方式及源碼示例解析
裝飾器(decorator)是一種高級Python語法,可以對一個函數(shù)、方法或者類進行加工,這篇文章主要介紹了Python?裝飾器常用的創(chuàng)建方式及解析,需要的朋友可以參考下2022-04-04
python實現(xiàn)DEM數(shù)據(jù)的陰影生成的方法
這篇文章主要介紹了python實現(xiàn)DEM數(shù)據(jù)的陰影生成的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07
python調(diào)用matplotlib模塊繪制柱狀圖
這篇文章主要為大家介紹了python調(diào)用matplotlib模塊繪制柱狀圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-10-10
Python環(huán)境管理virtualenv&virtualenvwrapper的配置詳解
這篇文章主要介紹了Python環(huán)境管理virtualenv&virtualenvwrapper的配置詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-07-07
python PyQt5中QRadioButton的詳細(xì)使用教程與應(yīng)用實戰(zhàn)
PyQt5是一個跨平臺的GUI工具包,用于創(chuàng)建具有Python綁定的Qt應(yīng)用程序,在PyQt5中,QRadioButton是一個非常有用的控件,用于在用戶界面上提供單選選項,本文將詳細(xì)介紹QRadioButton的基本用法、常用屬性和方法,需要的朋友可以參考下2024-08-08
Django日志和調(diào)試工具欄實現(xiàn)高效的應(yīng)用程序調(diào)試和性能優(yōu)化
這篇文章主要介紹了Django日志和調(diào)試工具欄實現(xiàn)高效的應(yīng)用程序調(diào)試和性能優(yōu)化,Django日志和調(diào)試工具欄為開發(fā)者提供了快速定位應(yīng)用程序問題的工具,可提高調(diào)試和性能優(yōu)化效率,提高應(yīng)用程序的可靠性和可維護性2023-05-05

