Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django python会话中存储的社交身份验证字段在我的自定义管道中始终为空_Django_Python Social Auth - Fatal编程技术网

Django python会话中存储的社交身份验证字段在我的自定义管道中始终为空

Django python会话中存储的社交身份验证字段在我的自定义管道中始终为空,django,python-social-auth,Django,Python Social Auth,我正在尝试从模板中获取会话社会变量。 我有两个单独的按钮用于注册和使用键登录类型登录: <a href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}?login_type=1"><img src='img.png'> </a> <a href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}?login_

我正在尝试从模板中获取会话社会变量。 我有两个单独的按钮用于注册和使用键登录类型登录:

<a href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}?login_type=1"><img src='img.png'>  </a>

<a href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}?login_type=2"><img src='img2.png'></a>
我也尝试过:

FIELDS_STORED_IN_SESSION = ['login_type']
我的自定义管道:

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',
'FBAuth.facebook.check_if_exists',     
'social.pipeline.user.get_username',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
)
facebook.py:

from django.conf import settings
from django.shortcuts import  redirect, HttpResponse

def check_if_exists(strategy,  request, *args, **kwargs):
    login_type = strategy.request.GET.get('login_type')
    #login_type = strategy.session_get('key') (I tried all cases)
    #login_type = request['login_type']
    #login_type = strategy.request['login_type']
    logger.debug("is_new parameter is %s", kwargs['is_new'])
    logger.debug("login_type is %s", login_type)
    if kwargs['is_new']:
        if login_type == 1:  
            return redirect('/', message ='Specified social account is not yet associate with any existent user, try to Sign up first')
    else: 
        if login_type == 2: 
            return redirect('/', message = 'User for this account is already exist, try to login')
    return None
但是,在任何情况下,在我的日志中,我总是看到“login\u type为None”


出什么事了?

看来你的参数搞错了。你应该改变

<code><pre>?next={{ request.path }}?login_type=1</pre></code>
?下一步={{request.path}?登录\u type=1

?下一步={{request.path}}&login\u type=1

看起来您的GET参数出错了。你应该改变

<code><pre>?next={{ request.path }}?login_type=1</pre></code>
?下一步={{request.path}?登录\u type=1

?下一步={{request.path}}&login\u type=1
<code><pre>?next={{ request.path }}&login_type=1</pre></code>