def post(self, request, *args, **kwargs): form = UserListForm(request.data) if not form.is_valid(): return Response({'Detail': form.errors}, status=status.HTTP_400_BAD_REQUEST) cld = form.cleaned_data user_list = self.get_user_list() serializer = UserListSerializer(user_list) list_data = serializer.list_data(**cld) if isinstance(list_data, Exception): return Response({'Detail': list_data.args}, status=status.HTTP_400_BAD_REQUEST) return Response(list_data, status=status.HTTP_200_OK)
def post(self, request, *args, **kwargs): form = UserListForm(request.data) if not form.is_valid(): return Response(form.errors, status=status.HTTP_400_BAD_REQUEST) cld = form.cleaned_data _objects = self.get_objects_list(request, **kwargs) if isinstance(_objects, Exception): return Response({'detail': _objects.args}, status=status.HTTP_400_BAD_REQUEST) serializer = UserListSerializer(data=_objects) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) results = serializer.list_data(**cld) if isinstance(results, Exception): return Response({'Error': results.args}, status=status.HTTP_400_BAD_REQUEST) return Response(results, status=status.HTTP_200_OK)