批量删除使用__in
try: case_stepid = request.POST.get('case_stepid', '') case_stepids = request.POST.get('case_stepids', '') case_stepids = case_stepids.split(',') //将a,b,c,d这样格式的字符串变为list列表 if case_stepid: CaseStep.objects.filter(case_stepid=case_stepid).delete() else: CaseStep.objects.filter(case_stepid__in=case_stepids).delete() //list批量删除 data = {"code": 200, "msg": "步骤删除成功"} data = json.dumps(data) return HttpResponse(data, content_type='application/json') except Exception as e: print(e) data = {"code": 500, "msg": "删除失败"} data = json.dumps(data) return HttpResponse(data, content_type='application/json')
标签:case,stepid,删除,批量,models,django,json,stepids,data From: https://www.cnblogs.com/sugoi/p/16857064.html