Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python - Django built in login view not redirecting to next

I am using django auth views for authentication but after successful login it should try to redirect the user to the next GET param but it is redirecting to LOGIN_REDIRECT_URL only! here is my url

    url(r'^login/$', auth_views.login, {'template_name': 'accounts/registered/login.html',}, name='login'),

in my setting.py

LOGIN_REDIRECT_URL = '/'

when a unauthenticated user wants to visit dashboard it automatically redirected to login page with next param

http://127.0.0.1:8000/accounts/login/?next=/accounts/dashboard/

but after successful login it redirects it to

http://127.0.0.1:8000/

it should redirect it according to next param.

like image 973
Pankaj Sharma Avatar asked Mar 07 '23 03:03

Pankaj Sharma


1 Answers

Looks like you forgot to add hidden field next to the accounts/registered/login.html template:

<input type="hidden" name="next" value="{{ next }}">
like image 69
catavaran Avatar answered Mar 24 '23 19:03

catavaran