Вопрос

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top