Django提示You have multiple authentication backends configured and therefore must provide the `backend

本文介绍了在Django中遇到因配置多个身份验证后端导致的验证码登录错误,提供了解决该问题的具体场景及解决方案。
摘要由CSDN通过智能技术生成

您配置了多个身份验证后端,因此必须为用户提供“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 &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值