您好,登錄后才能下訂單哦!
將數組傳遞給前臺模板:
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">環境</label><input type="text" name="env" class="equipment_sz" value={{x.2}}> <input type="submit" value="設備修改" 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將數組傳遞給前臺模板的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。