I performed this test:
class IsAuthenticatedView(APIView):
def get(self, request):
print(request.user)
return Response({
"is_authenticated": "true" if request.user.is_authenticated else "false"
}, 200)
and
class IsAuthenticatedView(View):
def get(self, request):
print(request.user)
return Response({
"is_authenticated": "true" if request.user.is_authenticated else "false"
}, 200)
The second one fails to load properly because of an AssertionError. However, the request.user changes among these two, where the APIView prints an AnonymousUser, the second prints the actual user logged in.
I'm using the Facebook login authentication.