您的位置:首页 > 编程语言 > Go语言

django中批量删除数据

2012-10-24 21:11 260 查看
我们在做批量删除的时候,通常都会在列表前面增加相同name的 inputtype="checkbox" name="ids" ,以供多选,在View里面我可以如下处理:

python 代码

 
def delete_ms(request):  
    ids = request.POST.getlist('ids')  
      
    idstring = ','.join(ids)  
      
    MonthScheme.objects.extra(where=['id IN ('+ idstring +')']).delete()  
      
    return HttpResponseRedirect("/manage/index/")  

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: