JSON serialized data not getting

I have this serializer:

class LoginSerializer(serializers.ModelSerializer):

    class Meta:
        model = User
        fields = ['id', 'username', 'email']

and I have this view to log a user in:

@api_view(["POST"])
def LoginUser(request):
    email = request.data['email']
    password = request.data['password']
    user = authenticate(email=email, password=password)
    if user is not None:
        token = Token.objects.get_or_create(user=user)[1]
        loggeduser = LoginSerializer(user)
        return Response({
            'token': token,
            'user': loggeduser
        }, status=HTTP_200_OK)

Please explain to me like I am 5. Why am I getting the error TypeError: Object of type LoginSerializer is not JSON serializable.

and why would a Response not return anything? I click and you can see the request going t5hrough but nothing happens so no way for me to check if it works or not.

Because the serializer is a object that serializes the data, and not the data serialized itself. Review the serializers docs from the DRF. To access the data, you do: loggeduser.data.

That may be to the error being raised, if a error is raised, then a 500 error response is returned.

Thank you I solved it and you were right