I am trying to update my user profile. But at the 'if data['password'] != '':' line, it's showing a KeyError at 'password'. I am understanding the data I called at request.data doesn't contain 'password', which is not making any sense. Please help me out, someone.
@api_view(['PUT'])
@permission_classes([IsAuthenticated])
def updateUserProfile(request):
user = request.user
serializer = UserSerializerWithToken(user, many=False)
data = request.data
user.first_name = data['name']
user.username = data['email']
user.email = data['email']
if data['password'] != '':
user.password = make_password(data['password'])
user.save()
return Response(serializer.data)