def create(self, request): serializer = UserSerializer(data=request.data) if serializer.is_valid(): serializer.save() # return Response(serializer.data, status=201) return Response(serializer.data, status=status.HTTP_201_CREATED) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def update(self, request, pk): user = get_object_or_404(User, pk=pk) self.check_object_permissions(request, user) serializer = UserSerializer(instance=user, data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_202_ACCEPTED) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)