问题描述
在我的应用程序中,我有一个?next参数,所以当用户登录时,他们将被重定向到他们来自哪里。例如www.mysite.com/login/?next=www.mysite.com/some-section /我正在使用进行Facebook注册。当用户登录时,它们将重定向到settings.py(settings.LOGIN_REDIRECT_URL)中指定的URL。
有没有办法传递重定向网址,例如像:
< a class =button-facebookhref ={%provider_login_urlfacebookmethod =oauth2next = redirecturl redirect_uri = redirecturl%}>
allauth配置中有一些适配器。例如这个:
ACCOUNT_ADAPTER(=allauth.account.adapter.DefaultAccountAdapter)
指定要使用的适配器类,允许您更改某些默认值
覆盖默认设置,并设置自己的设置:
settings.py
ACCOUNT_ADAPTER ='MyAdapter'
somewhere.py
class MyAdapter(DefaultAccountAdapter):
def get_login_redirect_url ,请求):
返回请求.GET ['next']
检查默认行为on:
In my app I have a "?next" param so when a user logs in they will be redirected to where they came from. example www.mysite.com/login/?next=www.mysite.com/some-section/
I am using django-allauth for Facebook registration. When a user logs in they are redirected to the url specified in settings.py (settings.LOGIN_REDIRECT_URL)
Is there a way to pass in the redirect url for example like so:
<a class="button-facebook" href="{% provider_login_url "facebook" method="oauth2" next=redirecturl redirect_uri=redirecturl %}">
There are some adapters on the allauth configuration. For example this one:
ACCOUNT_ADAPTER (="allauth.account.adapter.DefaultAccountAdapter") Specifies the adapter class to use, allowing you to alter certain default behaviour.
Override the default one and set your own on the settings:
settings.py
ACCOUNT_ADAPTER = 'MyAdapter'
somewhere.py
class MyAdapter(DefaultAccountAdapter):
def get_login_redirect_url(self, request):
return request.GET['next']
Check the default behavior on:https://github.com/pennersr/django-allauth/blob/master/allauth/account/adapter.py
这篇关于Django allauth - 设置Facebook重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!