django將數(shù)組傳遞給前臺(tái)模板的方法
將數(shù)組傳遞給前臺(tái)模板:
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>運(yùn)維平臺(tái)</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ù)組傳遞給前臺(tái)模板的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
幾個(gè)提升Python運(yùn)行效率的方法之間的對(duì)比
這篇文章主要介紹了幾個(gè)提升Python運(yùn)行效率的方法之間的對(duì)比,包括使用Cython和PyPy等這些熱門方法,需要的朋友可以參考下2015-04-04python?Scala函數(shù)與訪問修辭符實(shí)例詳解
這篇文章主要為大家介紹了python?Scala函數(shù)與訪問修辭符實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08np.where()[0] 和 np.where()[1]的具體使用
這篇文章主要介紹了np.where()[0] 和 np.where()[1]的具體使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03Python實(shí)現(xiàn)使用dir獲取類的方法列表
今天小編就為大家分享一篇Python實(shí)現(xiàn)使用dir獲取類的方法列表,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-12-12Python3之不使用第三方變量,實(shí)現(xiàn)交換兩個(gè)變量的值
今天小編就為大家分享一篇Python3之不使用第三方變量,實(shí)現(xiàn)交換兩個(gè)變量的值,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-06-06