为什么第二个用户登录将我重定向到/ accounts / profile / url? [英] Why second user login redirects me to /accounts/profile/ url?
问题描述
我正在使用Django内置的用户登录视图:
url(r'^ user / login / $' 'django.contrib.auth.views.login',{'template_name':'users / templates / login.html'},name ='user-login'),
pre>
登录后,当我转到用户/登录后,我可以第二次登录。我提交表单并获取:
当前的URL,accounts / profile /与这些不匹配。
我没有在
urls.py
中声明此网址。
我做错了什么?为什么框架要重定向到这个url?
解决方案
django.contrib.auth.views.login
在您登录后立即将您重定向到accounts / profile /
。
您可能需要设置LOGIN_REDIRECT_URL
在您的settings.py
文件内的任何你喜欢的东西..I am using Django built in view for user login:
url(r'^user/login/$', 'django.contrib.auth.views.login', {'template_name': 'users/templates/login.html'}, name='user-login'),
After login when I goto user/login again I can login second time. I submit the form and getting:
The current URL, accounts/profile/, didn't match any of these.
I haven't declare this url in
urls.py
.What I am doing wrong? Why framework want to redirect to this url?
解决方案
django.contrib.auth.views.login
redirects you toaccounts/profile/
right after you log in.
You may want to setLOGIN_REDIRECT_URL
inside yoursettings.py
file to anything you like..这篇关于为什么第二个用户登录将我重定向到/ accounts / profile / url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!