请求头中增加:
authorization = 'Token <Your token>'
req.add_header('Authorization', authorization)
问题: 'Token' has no attribute 'DoesNotExist'
原因:没有导入rest authon: 'rest_framework.authtoken',
解决方法:在 settings 里面 INSTALLED_APPS 中添加 'rest_framework.authtoken' 即可
问题:Exception Value: no such table: authtoken_token
执行:
python manage.py makemigrations
python manage.py migrate
更细一下表即可