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.