[Django]-Update User REST framework Django

2๐Ÿ‘

โœ…

   def post(self,request):
        user_serializer=UserSerializer(request.user, data=request.data, partial=True)
        if user_serializer.is_valid():
            user_serializer.save()
            return Response(user_serializer.data, status=status.HTTP_200_OK)
        else:
            return Response(user_serializer.errors, status=status.HTTP_400_BAD_REQUEST)
๐Ÿ‘คYkh

1๐Ÿ‘

@YKH is right this code is good there may error in your POST data.

In your image, you are passing two parameters in Header. It could possible you are passing the wrong header.
Content-Type should not be for form-data

๐Ÿ‘คtarun sharma

1๐Ÿ‘

I found this post where someone has a similar problem as you: Django Rest Framework unable to parse multipart/form data

It seems on your picture that you are putting something into Headers tab. Postman is taking care of that for you, so you shouldnโ€™t define anything there. Could you try again without setting anything in the headers?

๐Ÿ‘คtagette

Leave a comment