Django Rest Framework Token Authentication

前端 未结 7 1269
北荒
北荒 2020-12-07 08:24

I have read the Django Rest Framework Guides and done all the tutorials. Everything seemed to make sense and work just how it should. I got basic and session authentication

7条回答
  •  借酒劲吻你
    2020-12-07 09:01

    There is a cleaner way to get the user token.

    simply run manage.py shell

    and then

    from rest_framework.authtoken.models import Token
    from django.contrib.auth.models import User
    u = User.objects.get(username='admin')
    token = Token.objects.create(user=u)
    print token.key
    

    then a record should be found in table DB_Schema.authtoken_token

提交回复
热议问题