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
Source:stackexchange.com