问题
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.
回答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
class SocialAccountAdapter(DefaultSocialAccountAdapter):
def get_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:
class SocialAccountAdapter(DefaultSocialAccountAdapter):
...
def save_user(self, request, sociallogin, form=None):
super(DefaultSocialAccountAdapter, self).save_user(request, sociallogin, form=form)
# your logic here... and return redirection afterward
return redirect(...)
回答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
来源:https://stackoverflow.com/questions/27759407/django-allauth-redirect-after-social-signup