class TaskDeleteSelectView(View):
def post(self, request):
if not request.user.is_authenticated:
# 判断用户登录状态
return HttpResponse('{"status":"fail", "msg":"用户未登录"}', content_type='application/json')
array = request.POST.getlist('ids') # django接收数组
idstring = ','.join(array)
try:
Tasklist.objects.extra(where=['id IN (' + idstring + ')']).delete()
except:
return HttpResponse('{"status":"fail", "msg":"ID不存在"}', content_type='application/json')
return HttpResponse('{"status":"success", "msg":"操作成功"}', content_type='application/json')
https://blog.csdn.net/liangpz521/article/details/8108793