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编写脚本使IE实现代理上网的教程

厂里上个网需要设置代理服务器,切换各种环境『包括但不仅限于开发环境、QA、预上线、验收、生产环境、压力测试、Demo……』都需要给浏览器设置不同的代理服务器。 虽然俺有神器Firefox...

python实现超简单端口转发的方法

本文实例讲述了python实现超简单端口转发的方法。分享给大家供大家参考。具体如下: 代码非常简单,实现了简单的端口数据转发功能,用于真实环境还需要再修改一下。 复制代码 代码如下:#t...

python使用json序列化datetime类型实例解析

使用python的json模块序列化时间或者其他不支持的类型时会抛异常,例如下面的代码: # -*- coding: cp936 -*- from datetime import d...

Django的分页器实例(paginator)

先导入模块: from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger 分页器paginat...

利用python GDAL库读写geotiff格式的遥感影像方法

如下所示: from osgeo import gdal import numpy as np def read_tiff(inpath): ds=gdal.Open(inpat...