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通过正则表达式选取callback的方法

本文实例讲述了Python通过正则表达式选取callback的方法。分享给大家供大家参考。具体如下: 最近在瞎想怎么通过xpath去精确抓取文章的正文,跟parselets类似的想法,只...

PyQt5图形界面播放音乐的实例

安装Pygame pip install pygame import time import pygame pygame.init() print("播放音乐1") track =...

python去掉 unicode 字符串前面的u方法

有时我们会碰到类似下面这样的 unicode 字符串: u'\xe4\xbd\xa0\xe5\xa5\xbd' 这明显不是一个正确的 unicode 字符串,可能是在哪个地方转码转...

Python使用scrapy采集数据时为每个请求随机分配user-agent的方法

本文实例讲述了Python使用scrapy采集数据时为每个请求随机分配user-agent的方法。分享给大家供大家参考。具体分析如下: 通过这个方法可以每次请求更换不同的user-age...

Python时间获取及转换知识汇总

 时间处理是我们日常开发中最最常见的需求,例如:获取当前datetime、获取当天date、获取明天/前N天、获取当天开始和结束时间(00:00:00 23:59:59)、获取...