I go to my webpage http://localhost:8000/listings/post/, it fails the test
@user_passes_test(lambda u: u.is_authenticated() and u.get_profile().shipper)
as expected, and redirects me to http://localhost:8000/login/?next=/listings/post/ like it's supposed to, but when I log in again, it doesn't redirect me back to that page like it's supposed to. It takes me to /accounts/profile/. I haven't defined redirect_field_name anywhere, so it should be looking for the default next variable. The relevant urls.py bit looks like this
url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
So what are the possible causes for this?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With