django 控制页面跳转的例子

yipeiwu_com6年前Python基础

如下所示:

def delEquipment(request, delip):
  print delip
  ip=delip
  conn= MySQLdb.connect(
    host='localhost',
    port = 3306,
    user='root',
    passwd='1234567',
    db ='DEVOPS'
    )
  cursor = conn.cursor()
  #a = cur.execute("select ip,info,env from machine_info where env=%s ",[group])
  try :
   cursor.execute("delete from machine_info where ip=%s",[ip])
   conn.commit()
   return redirect('/cmdb/modifyIndex')
  except :
   conn.rollback()
   return HttpResponse('del failed')

django 页面跳转:

 return redirect('/cmdb/modifyIndex')
 
 
url(r'^cmdb/modifyIndex/$', newview.modifyIndex),
 
 
def modifyIndex(req):
  return render_to_response('cmdb/modifyIndex.html')

以上这篇django 控制页面跳转的例子就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python3标准库总结

Python3标准库 操作系统接口 os模块提供了不少与操作系统相关联的函数。 >>> import os >>> os.getcwd()...

python dict remove数组删除(del,pop)

比如代码 binfo = {'name':'jay','age':20,'python':'haha'} print binfo.pop('name')#pop方法删除键,并且返回键对应...

Python tkinter模块弹出窗口及传值回到主窗口操作详解

Python tkinter模块弹出窗口及传值回到主窗口操作详解

本文实例讲述了Python tkinter模块弹出窗口及传值回到主窗口操作。分享给大家供大家参考,具体如下: 有些时候,我们需要使用弹出窗口,对程序的运行参数进行设置。有两种选择 一、标...

Python拼接微信好友头像大图的实现方法

Python拼接微信好友头像大图的实现方法

基于 itchat 库来获取微信好友头像并执行拼接操作,对微信上文字化好友列表数据进行可视化展示。 获取好友头像 def save_avatar(folder): """ 保...

Python Sqlite3以字典形式返回查询结果的实现方法

sqlite3本身并没有像pymysql一样原生提供字典形式的游标。 cursor = conn.cursor(pymysql.cursors.DictCursor) 但官方文...