Django中使用djangorestframework产生Token
修改settings.py:
INSTALLED_APPS添加rest_framework
产生Token
from rest_framework.authtoken.models import Token
Token.objects.update_or_create(user=request.user)
获取Token
from rest_framework.authtoken.models import Token
Token.objects.get(user=request.user)