我正在使用django-social-auth通过facebook登录我的用户 . 在登录过程中,我需要将用户重定向到页面以更改从Facebook检索到的 Profiles 信息 . 我使用管道来实现这一目标 . 但是当我使用httpresponseredirect时,在view函数中request.user以匿名用户身份返回 .

这是我的功能:

setting.py

SOCIAL_AUTH_PIPELINE = (
    'social_auth.backends.pipeline.social.social_auth_user',
    'social_auth.backends.pipeline.associate.associate_by_email',
    'social_auth.backends.pipeline.user.get_username',
    'social_auth.backends.pipeline.social.load_extra_data',
    'social_auth.backends.pipeline.user.create_user',
    'social_auth.backends.pipeline.social.associate_user',
    'social_auth.backends.pipeline.user.update_user_details',
    'feedreader.pipelines.get_user_avatar', 
    'social_auth.backends.pipeline.misc.save_status_to_session',
    'feedreader.pipelines.redirect_to_form',   
)

pipelines.py

def redirect_to_form( request,user, is_new = False, *args, **kwargs):

    if is_new:

        return HttpResponseRedirect(reverse('user_profile.views.confirm_user_profile',kwargs={}))
    return {'social_user': social_user,
                'user': user}

管道feedreader.pipelines.get_user_avatar工作正常,如果我在redirect_to_form中检查用户就可以了 .

如果我用户在confirm_user_profile中打印request.user,它将返回匿名用户 . 我搜索了SO,还有其他帖子暗示用户信息在重定向过程中丢失,但没有建议或工作解决方案 .

提前致谢 .