def update(self, request, *args, **kwargs): user = request.user queryset = self.get_queryset()[0] serializer = CauseSerializer(queryset, data=request.data, partial=True) if serializer.is_valid(): serializer.save(creator=user) return Response(serializer.data, status=status.HTTP_202_ACCEPTED) else: return Response({ 'status': "400", 'message': serializer.errors }, status=status.HTTP_400_BAD_REQUEST)
def create(self, request, *args, **kwargs): data = request.data user = request.user serializer = CauseSerializer(data=data, partial=True) if serializer.is_valid(): serializer.save(creator=user) return Response(serializer.data, status=status.HTTP_201_CREATED) else: return Response({ 'status': "400", 'message': serializer.errors }, status=status.HTTP_400_BAD_REQUEST)