您配置了多个身份验证后端,因此必须为用户提供“backend”参数或设置“backend”属性。
setting.py 配置用户认证
AUTHENTICATION_BACKENDS = (
# Django默认default
'django.contrib.auth.backends.ModelBackend',
'guardian.backends.ObjectPermissionBackend',
# 微信登录验证
'social_core.backends.weixin.WeixinOAuth2',
# 微博登录验证
# 'social.backends.weibo.WeiboOAuth2',
# QQ登录验证
# 'social.backends.qq.QQOAuth2',
)
我的场景是处理验证码登录报错
You have multiple authentication backends configured and therefore must provide the backend
argument or set the backend
attribute on the user.
class PhoneCode(APIView):
"""
作者:阳光男孩 2020/11/13
功能:用户手机号验证码登录
"""
# 不作认证和授权
authentication_classes = []
permission_classes &