简体   繁体   English

成功登录后django-user-accounts不会重定向

[英]django-user-accounts don't redirect after successful login

I use django-user-accounts app in my project. 我在项目中使用django-user-accounts应用程序。 I can't understand strange behavior. 我无法理解奇怪的行为。 When user try to login nothing happens. 当用户尝试登录时,没有任何反应。 After successful login I want to redirect user. 成功登录后,我要重定向用户。 Why ACCOUNT_LOGIN_REDIRECT_URL setting don't work? 为什么ACCOUNT_LOGIN_REDIRECT_URL设置不起作用?

settings.py: settings.py:

ACCOUNT_LOGIN_REDIRECT_URL = reverse_lazy('dashboard')

Also I tried to use LOGIN_REDIRECT_URL = reverse_lazy('dashboard') but result was the same. 我也尝试使用LOGIN_REDIRECT_URL = reverse_lazy('dashboard')但是结果是一样的。

urls.py: urls.py:

url(r"^account/", include("account.urls")),

templates/account/login.html: template / account / login.html:

<form method="post" action="">
    {% csrf_token %}
    {% render_field form.username|add_class:"form-control" placeholder="Username" %}
    {% render_field form.password|add_class:"form-control" placeholder="Password" %}
    <input type="hidden" name="next" value="{{ next }}"/>
</form>

In console I see next: 控制台中,我看到下一个:

[26/May/2018 14:31:38] "GET /account/login/ HTTP/1.1" 200 4018

Login redirect settings need to be a plain & simple string. 登录重定向设置必须为简单的字符串。 Using reverse for these doesn't work. 对这些使用reverse不起作用。

Docs are here 文件在这里

ACCOUNT_LOGIN_REDIRECT_URL = '/dashboard/'

If you need to do anything complicated with the redirect like figure out what user has logged in & redirect to a certain place then make the above setting a view that has the logic in it to do what you need to do. 如果您需要对重定向进行任何复杂的操作,例如弄清楚哪些用户已登录并重定向到某个特定位置,请在上面的视图中设置一个视图,其中包含执行所需操作的逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM