概述
有线的是,即使我输入了http … / complete / backend-name,页面也会重定向回密码集合页面.看起来渲染进入无限循环,密码收集页面首先指向完整页面,完整页面直接返回密码收集页面.我检查了REDIRECT_FIELD_NAME的值,它是“下一步”.
settings.py
SOCIAL_AUTH_PIPELINE = ( ... 'accounts.pipeline.get_password',... )
pipeline.py
from django.shortcuts import redirect from social.pipeline.partial import partial @partial def get_password(strategy,details,user=None,is_new=False,*args,**kwargs): if is_new: return redirect('accounts_signup_social') else: return
views.py
def get_password(request): if request.method == 'POST': request.session['password'] = request.POST.get('password') backend = request.session['partial_pipeline']['backend'] return redirect('social:complete',backend=backend) return render_to_response('accounts/social_signup.html',{"form":SocialSignUpForm},RequestContext(request))
正如文档所说,“管道将恢复与削减流程相同的功能.”在http://python-social-auth.readthedocs.org/en/latest/pipeline.html.这意味着它将始终渲染回相同的功能.
解决方案是在管道中添加密码的会话检查.如果密码存档,则返回下一个管道:
管道:
from django.shortcuts import redirect from social.pipeline.partial import partial @partial def get_password(strategy,**kwargs): if is_new: if 'password' in kwargs['request'].session: return {'password': kwargs['request'].session['psssword']} else: return redirect('accounts_signup_social') else: return
总结
以上是编程之家为你收集整理的django – python-social-auth部分管道无法恢复全部内容,希望文章能够帮你解决django – python-social-auth部分管道无法恢复所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧