Cod*_*mon 6 python django django-socialauth facebook-login
所以我想在登录后重定向到同一页面。但 Django Social Auth 不会重定向。它重定向到"/pins/#_=_
网页:
<a href="{% url socialauth_begin 'facebook' %}?next={{ request.get_full_path }}">Facebook Login</a>
Run Code Online (Sandbox Code Playgroud)
网址.py
url(r'^$', 'pinry.core.views.home', name='home')
Run Code Online (Sandbox Code Playgroud)
视图.py
def home(request):
if request.user.is_authenticated():
if 'next' in request.GET:
return HttpResponseRedirect(request.GET['next'])
else:
return HttpResponseRedirect('/pins'))
return HttpResponseRedirect(reverse('core:concept'))
Run Code Online (Sandbox Code Playgroud)
设置.py
LOGIN_URL = '/login-form/'
LOGIN_REDIRECT_URL = '/'
LOGIN_ERROR_URL = '/login-error/'
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/'
SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/pins/'
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = '/new-association-redirect-url/'
SOCIAL_AUTH_DISCONNECT_REDIRECT_URL = '/account-disconnected-redirect-url/'
SOCIAL_AUTH_BACKEND_ERROR_URL = '/new-error-url/'
SOCIAL_AUTH_COMPLETE_URL_NAME = 'socialauth_complete'
SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'
SOCIAL_AUTH_DEFAULT_USERNAME = 'new_social_auth_user'
TEMPLATE_CONTEXT_PROCESSORS = (
...
"social_auth.context_processors.social_auth_by_name_backends",
'social_auth.context_processors.social_auth_backends',
'social_auth.context_processors.social_auth_by_type_backends',
'social_auth.context_processors.social_auth_login_redirect',
"django.core.context_processors.csrf"
)
Run Code Online (Sandbox Code Playgroud)
我遇到了和你一样的问题,我通过更改登录按钮 URL 解决了这个问题
<a href="{% url 'social:begin' 'github' %}>
到
<a href="{% url 'social:begin' 'github' %}?next={{ request.GET.next }}>
| 归档时间: |
|
| 查看次数: |
3163 次 |
| 最近记录: |