python-在登录视图中内置的Django无法重定向到next [英] python - Django built in login view not redirecting to next
问题描述
我正在使用django auth视图进行身份验证,但是成功登录后,它应该尝试将用户重定向到下一个GET参数,但仅重定向到LOGIN_REDIRECT_URL!
这是我的网址
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'),
我的setting.py
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.
推荐答案
好像您忘了将隐藏字段 next
添加到 accounts / registered / login.html
模板:
Looks like you forgot to add hidden field next
to the accounts/registered/login.html
template:
<input type="hidden" name="next" value="{{ next }}">
这篇关于python-在登录视图中内置的Django无法重定向到next的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!