Django, request.user is always Anonymous User

后端 未结 9 2086
无人共我
无人共我 2020-12-01 14:57

I am using a custom authentication backend for Django (which runs off couchdb). I have a custom user model.

As part of the login, I am doing a request.user = u

9条回答
  •  春和景丽
    2020-12-01 15:35

    Added these in my view

    from rest_framework.permissions import IsAuthenticated
    from rest_framework.authentication import TokenAuthentication
    
    authentication_classes = (TokenAuthentication,)
    permission_classes = (IsAuthenticated,)
    

    and started getting original user

提交回复
热议问题