in Pinax, if I have a link that required login (i.e., I use the @login_required decorator), how do I redirect to that link after logging in, instead of being redirected to “what’s next”???
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simply set the LOGIN_REDIRECT_URL setting.
EDIT
It seems Pinax also supports another setting, LOGIN_REDIRECT_URLNAME, which seems to do the same thing as LOGIN_REDIRECT_URL, but is set to the url name, presumably so you don’t have to make a call to
reversein your settings.py file.For more ‘dynamic’ redirects, the pinax.apps.account.views.login view uses pinax.apps.account.utils.get_default_redirect to look for a redirect URL from the following:
The code in
get_default_redirectactually is checking in the session for a ‘redirect_to’ key, which presumably holds one of the values defined in the settings, as the method makes no attempt to look atdjango.conf.sessionon it’s own. The docstring claims that it checks for those settings, however, and that seems to be what you are experiencing in your project.