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及Pycharm安装方法图文教程

Python及Pycharm安装方法图文教程

Python及Pycharm安装方法,供大家参考,具体内容如下 1、任务简介 为了学习Python我今天对它进行了安装,整个安装过程忘了截图,故我在虚拟机中重新安装了一遍,并将Pytho...

python matplotlib坐标轴设置的方法

python matplotlib坐标轴设置的方法

在使用matplotlib模块时画坐标图时,往往需要对坐标轴设置很多参数,这些参数包括横纵坐标轴范围、坐标轴刻度大小、坐标轴名称等 在matplotlib中包含了很多函数,用来对这些...

Python列表list常用内建函数实例小结

本文实例总结了Python列表list常用内建函数。分享给大家供大家参考,具体如下: >>> x = list(range(10)) >>> im...

Python实现的调用C语言函数功能简单实例

Python实现的调用C语言函数功能简单实例

本文实例讲述了Python实现的调用C语言函数功能。分享给大家供大家参考,具体如下: 实例参考python cookbook 中的15.1节中的例子P612页 先把 c文件编译成 so文...

python中将阿拉伯数字转换成中文的实现代码

复制代码 代码如下: #!/usr/bin/python #-*- encoding: utf-8 -*- import types class NotIntegerError(Exce...