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设计】。

相关文章

Python中的下划线详解

这篇文章讨论Python中下划线_的使用。跟Python中很多用法类似,下划线_的不同用法绝大部分(不全是)都是一种惯例约定。 一、 单个下划线直接做变量名(_) 主要有三种情...

window7下的python2.7版本和python3.5版本的opencv-python安装过程

花费了整整2天的时间终于学会安装了opencv,换系统的心都有了,由于ubuntu实在不会玩,看来还是老老实实在windows下安装吧,以此作为记录方便以后安装 python2.7版本的...

通过cmd进入python的实例操作

通过cmd进入python的实例操作

通过cmd启动Python需要先设置系统环境,设置步骤如下: 1、首先,在桌面找到 “计算机” 右键 找到 “属性”或者按下 win 键 再右键“计算机” 找到 “属性”也可以。如下图所...

python通过自定义isnumber函数判断字符串是否为数字的方法

本文实例讲述了python通过自定义isnumber函数判断字符串是否为数字的方法。分享给大家供大家参考。具体如下: ''' isnumeric.py test a numeric...

python用户管理系统

本文实例为大家分享了Python用户管理系统的具体代码,供大家参考,具体内容如下 用户管理系统 1.注册新用户 如果注册用户已经存在,则报错 需要填写信息: name, passw...