[Django]-Next query parameter doesn't work with django allauth for facebook login

4👍

You need to override the get_login_redirect_url method of django-allauth.

For this inherit the DefaultAccountAdapter class as

from allauth.account.adapter import DefaultAccountAdapter

class MyAccountAdapter(DefaultAccountAdapter):
    def get_login_redirect_url(self, request):
        # get the next parameter from request object and return the url 

And make changes on settings.py

ADAPTER = "APPNAME.FILENAME.MyAccountAdapter"
ACCOUNT_ADAPTER = "APPNAME.FILENAME.MyAccountAdapter"

This should work !

1👍

How are you generating the Facebook login link? Most likely you are not indicating the next parameter there. The allauth documentation gives this example:

<a href="{% provider_login_url "openid" openid="..." next="/success/url/" %}">Google</a>

To get the proper next parameter you can access request.GET.next.

Leave a comment