问题描述
在我使用装饰器login_required()选择了一些视图之后,用户被重定向到: http://example.com/登录/? next =/anuncio/adicionar/,对吗?
After I choose some view with the decorator login_required() the user is redirected to: http://example.com/login/?next=/anuncio/adicionar/, right?
但是,在我使用使用Facebook登录"之后,用户被重定向到 http://example .com/login/# = 而不是 http://example. com/anuncio/adicionar/
But, after I use "Login with facebook", the user are redirected to http://example.com/login/#= instead of http://example.com/anuncio/adicionar/
只有在我使用python-social-auth时才会发生,而在使用auth本机登录名时则不会发生.
It happens only if I use the python-social-auth, and not happens if I use the auth native login.
我的注册/login.html-Python社交身份验证链接
My registration/login.html - Python Social Auth link
<a class="btn btn-social btn-fw btn-lg btn-facebook" href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}"><i class="fa fa-facebook"></i> Fazer login com Facebook</a>
和我的Auth本机登录名
and my Auth native login
<form action="{% url "auth:login" %}" role="form" method="POST">{% csrf_token %}
推荐答案
将登录重定向URL添加到您的settins.py文件
Add login redirect url to your settins.py file
LOGIN_REDIRECT_URL = '/anuncio/adicionar/'
因此,当用户通过身份验证时,它将重定向上述网址
so when user is authenticated it will tedirect the above url
这篇关于Python社交身份验证重定向到相同的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!