def post(self,request): # action的批量处理 print(request.POST) func_str = request.POST.get('action') data = request.POST.getlist('selected_pk_list') if not hasattr(self,func_str): return HttpResponse('非法输入') else: func = getattr(self, func_str) func(data) ret = self.get(request) return ret def patch_delete(self,data): Customer.objects.filter(pk__in=data).updata(sex='female')