Skip to content Skip to sidebar Skip to footer

Django Allauth Redirect After Social Signup

I would like to redirect to a certain link after social signup, how and where do I do that? I can do it for regular signup but I can't for social signup.

Solution 1:

Alternatively you can write your own custom social account adapter to handle different logged in redirection from different social accounts and not messing with your normal account settings, like so:

# adapter.py    from allauth.socialaccount.adapter import DefaultSocialAccountAdapter

classSocialAccountAdapter(DefaultSocialAccountAdapter):
    defget_login_redirect_url(self, request):
        # do your logic here for different social accounts
        ...
        return'url/to/your/redirection'# or reverse(view) or whatever# settings.py
SOCIALACCOUNT_ADAPTER = "point.to.adaptor.SocialAccountAdapter"

Edited:

In case you want to alter the redirection for newly signed up, you may customise adapter's save_user method:

classSocialAccountAdapter(DefaultSocialAccountAdapter):
    ...
    defsave_user(self, request, sociallogin, form=None):
        super(DefaultSocialAccountAdapter, self).save_user(request, sociallogin, form=form)
        # your logic here... and return redirection afterwardreturn redirect(...)

Solution 2:

After both social and normal it should be redirecting to your LOGIN_REDIRECT_URL in settings. Do you have that set?

Theres also some good information here about custom redirection

Post a Comment for "Django Allauth Redirect After Social Signup"