热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Python社交authDjango管道非类型错误

如何解决《Python社交authDjango管道非类型错误》经验,为你挑选了1个好方法。

我在Django设置文件中使用python-social-auth模块进行Facebook登录时有以下pipleline:

SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.get_username',
    'social.pipeline.user.user_details',
    'social.pipeline.social_auth.associate_by_email',
)

我的登录方法如下:

当我第一次尝试使用Facebook进行身份验证时,我得到以下内容:/ error/facebook /'NoneType'对象中的AttributeError没有属性'provider'

def user_login(request):
    """ Login page view."""

    #cOntext= RequestContext(request)
    cOntext= RequestContext(request,
                             {'request': request,
                              'user': request.user})

    user = request.user

    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username, password=password)  # authentication

    if not user.is_anonymous():
        print user
        if not request.method == 'POST':

            user.backend = 'django.contrib.auth.backends.ModelBackend'
        if user.is_active:
            login(request, user)
            return HttpResponseRedirect('/')
        else:
            return render_to_response('main/login.html', {}, context)

    else:
        return render_to_response('main/login.html', {}, context)

但是,如果我注释掉了SOCIAL_AUTH_PIPELINE并尝试登录,那就没关系了.当然,一旦社交认证用户在数据库中,Pipleline就能正常工作.

我很感激任何寻找错误的想法.



1> K.H...:

这可能不是你的原因,因为在我的情况下,无论管道是什么,我都会得到这个错误,但它可能会帮助别人.

在我的情况下,我得到了这个错误,因为我从auth_user表中删除了用户,但是表中仍然存在social_auth_usersocialauth指向不存在的用户ID的记录,这阻止了用正确的用户创建记录.在我的情况下,通过从social_auth_usercoaialauth表中删除记录或修复该记录以指向现有用户ID来解决这个问题.


推荐阅读
author-avatar
小馨小慧
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有