django rest auth returns AnonymousUser

You are not using Django-rest-framework in right way. Change your view like this

class CheckAuth(generics.GenericAPIView):

    def post(self, request):
        print(request.user)
        if request.user.is_authenticated():
             content = {'message': 'Authenticated'}
             return Response(content, status=200)
        else:
             content = {'message': 'Unauthenticated'}
             return Response(content, status=401)

You can further see Django-rest docs about views here.


For my case i had to add @api_view(['POST']) at the begging of the function

@csrf_exempt
@api_view(['POST'])
def send_message(request):
    if request.user.is_authenticated: