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,

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top