【发布时间】:2019-04-15 15:44:30
【问题描述】:
我在 drf 中使用 allauth 进行身份验证。我能够注册新用户并使用凭据登录。 登录 api 返回响应如下:
{
"key" : "<some token>"
}
现在我还有 1 个 API,其代码是
from django.http import HttpResponse
def lol(request):
if request.user.is_authenticated:
return HttpResponse("Authenticated")
else:
return HttpResponse("Not Authenticated")
这是我的 settings.py 中已安装应用程序的列表
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'django.contrib.sites',
'allauth',
'allauth.account',
'rest_auth.registration',
'api.user',
'api.activity',
]
【问题讨论】:
标签: django python-3.x django-rest-framework django-allauth