django-allauth 之后没有将我重定向到下一页

时间:2020-12-28 21:14:26

标签: django django-allauth

我正在使用 Django 3.0.9django-allauth 0.42.0 包。

我已经实现了登录、注册、重置密码和注销页面。在所有这些中,当我单击相应的表单按钮时,我不会被重定向到下一页。但是,操作正在完成 - 如果我手动刷新页面,我可以看到我已登录/退出等。

无论是从浏览器还是从 Django 日志中,我都不会随时随地收到任何错误或警告消息。

例如,这是我的代码查找登录页面的方式。为清楚起见,我删除了大量 CSS、HTML 等内容:

login.html:

{% load static i18n %}
{% load i18n %}
{% load account socialaccount %}
{% load crispy_forms_tags %}

{% get_providers as socialaccount_providers %}

{% if socialaccount_providers %}
<p>{% blocktrans with site.name as site_name %}Please sign in with one
of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>

<div class="socialaccount_ballot">

    <ul class="socialaccount_providers">
    {% include "socialaccount/snippets/provider_list.html" with process="login" %}
    </ul>

    <div class="login-or">{% trans 'or' %}</div>

</div>

{% include "socialaccount/snippets/login_extra.html" %}

{% else %}
<p>{% blocktrans %}If you have not created an account yet, then please
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
{% endif %}

<section id="contact">
    <div>
    <div>
        <div>
        <h2>{% trans "Sign In" %}</h2>
        </div>
    </div>

    <div class="row justify-content-center">
        <div class="col-lg-5 col-md-8">
        <div class="form">
            <form action="{% url 'account_login' %}" method="post" role="form">
            {% csrf_token %}
            {{ form|crispy }}
            {% if redirect_field_value %}
            <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
            {% endif %}
            <a class="button" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
            <button id="signInBtn" class="btn btn-primary" type="submit">{% trans "Sign In" %}</button>
            </form>
        </div>
        </div>

    </div>
    </div>
</section>

另外,这是我的配置:

LOGIN_REDIRECT_URL = "users:redirect"

# https://docs.djangoproject.com/en/dev/ref/settings/#login-url
LOGIN_URL = "account_login"

你能看到我在这里遗漏了什么吗?

0 个答案:

没有答案