Py学习  »  问与答

django redirect next失效

hackergodness • 7 年前 • 2067 次点击  

登录页面会话失效后,需要重新登录,页面url如下: http://127.0.0.1:8888/login/?next=/storage/stg/ 但是通过login认证后,不会重定向到/storage/stg/,而是跳转到默认页面。 求大牛指点,是哪里没配置对? Django 版本1.10

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/1642
 
2067 次点击  
文章 [ 4 ]  |  最新文章 7 年前
TMAC狂热-weibo
Reply   •   1 楼
TMAC狂热-weibo    7 年前

If called via POST with user submitted credentials, it tries to log the user in. If login is successful, the view redirects to the URL specified in next. If next isn’t provided, it redirects to settings.LOGIN_REDIRECT_URL (which defaults to /accounts/profile/). If login isn’t successful, it redisplays the login form.

TMAC狂热-weibo
Reply   •   2 楼
TMAC狂热-weibo    7 年前

django中登陆你如果调用的是默认的django.contrib.auth.views.login视图函数的话,你需要在settings.py下配置 LOGIN_REDIRECT_URL = 登录成功后转向的url

TMAC狂热-weibo
Reply   •   3 楼
TMAC狂热-weibo    7 年前

貌似是需要 你在settings.py下面设置一个url用于跳转

TMAC狂热-weibo
Reply   •   4 楼
TMAC狂热-weibo    7 年前

贴下代码