为什么第二个用户登录将我重定向到/ accounts / profile / url? [英] Why second user login redirects me to /accounts/profile/ url?

查看:1230
本文介绍了为什么第二个用户登录将我重定向到/ 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 to accounts/profile/ right after you log in.
You may want to set LOGIN_REDIRECT_URL inside your settings.py file to anything you like..

这篇关于为什么第二个用户登录将我重定向到/ accounts / profile / url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆