[Answered ]-Django login AttributeError: 'AnonymousUser' object has no attribute '_meta'

2πŸ‘

βœ…

In DRF user should be authenticated inside Authentication class. This library provides one for JWT auth. It provides both token generation and verification.

You will get user as self.request.user in your View or ViewSet class. You just need to allow JWT auth:

class ExampleView(APIView):
    authentication_classes = (BasicAuthentication, JSONWebTokenAuthentication)

Or better set is as DEFAULT_AUTHENTICATION_CLASSES as documented here.

πŸ‘€Raz

Leave a comment