Get user object from token string in DRF?

后端 未结 5 954
逝去的感伤
逝去的感伤 2021-02-09 16:36

I have a token string from Django REST Framework\'s TokenAuthentication.

I need to get the corresponding user object. How would I go about doing this?

5条回答
  •  温柔的废话
    2021-02-09 16:53

    from rest_framework.authtoken.models import Token
    user = Token.objects.get(key='token string').user
    

提交回复
热议问题