[Solved]-Django login redirect not working?

17👍

Needed to add

<input type="hidden" name="next" value="{{ next }}" />

To my login form. It was posting back to the login URL without the next token, and then trying to redirect.

👤mpen

4👍

It redirects you to the settings variable LOGIN_REDIRECT_URL.

This happens when the following is true:

if not redirect_to or '//' in redirect_to or ' ' in redirect_to:
                redirect_to = settings.LOGIN_REDIRECT_URL

Most probably your ‘next’ variable is empty or contains garbage.

Leave a comment