Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

redirect Django to custom page after social login and then redirecting to previous page using ?next

In django,

When user logs in using Login from google, I am redirecting it to /user/profile/picture/ where I am doing some code to store profile picture in another table.

Then I want to redirect the user to previous page where he/she clicked Siginin in with google


What I have tried:

In settings.py

LOGIN_REDIRECT_URL = '/user/profile/picture/'

In home.html

<a href="{% provider_login_url 'google' %}?next={{request.path}}">

The main problem is here. Django redirects to /user/profile/picture/ and it loses the next parameter. And if I remove the line LOGIN_REDIRECT_URL = '/user/profile/picture/, the problem is that it will not create a new row in table for setting profile picture and it will directly redirect to previous page using next paramter.


What I want?

I want django to redirect me first to user/profile/picture and then redirect me to the previous page where user clicked on Sigin with Google

PS: I am using django 3.0.5 if it makes any difference.

question from:https://stackoverflow.com/questions/65857049/redirect-django-to-custom-page-after-social-login-and-then-redirecting-to-previo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...