Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django registration login redirection

With django-registration, I have in settings.py:

LOGIN_REDIRECT_URL = '/'

When I'm trying to access a page (signed out) like http://localhost:8000/surfboards/current/, I'm redirected to http://localhost:8000/accounts/login/?next=/surfboards/current/

In that case, if the next parameter is specified, I'd like to be after login successfully redirected to this page, and not to the default LOGIN_REDIRECT_URL.

For now, I'm always redirected to http://localhost:8000/, which is what I want only if next isn't specified.

Thanks,

like image 990
Dachmt Avatar asked Dec 20 '22 06:12

Dachmt


1 Answers

django login view is internally used by django-registration for login. And login view provided by django takes care of next.

I guess you are missing sending it from the template.

Do you have following line in registration/login.html?

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

If not, then add it, and your issue should be fixed.

like image 193
Akshar Raaj Avatar answered Jan 02 '23 00:01

Akshar Raaj