You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法删除登录页Forgot Password?链接,Django-allauth配置无响应求助

问题:无法移除Django-allauth登录页的“忘记密码?”链接

我想去掉登录页面上的“忘记密码?”链接,但所有操作都没效果,看起来Django在调用某个找不到的默认代码。

我用的是最近更新的django-allauth库,之前的代码应该是能正常工作的。自定义的templates/allauth/account/login.html里的调试文本能正常显示,但登录页上的“忘记密码?”链接还是存在;templates/allauth/account/password_change.html里已经把相关代码注释掉了,服务器却没反应。

我试过调整模板结构、更新settings里的配置来关联allauth、甚至删除password_change.html,部署后页面都没有任何变化。

相关代码示例

login.html代码

{% extends "base.html" %}

{% load i18n %}
{% load account socialaccount %}

{% block head_title %}{% trans "Sign In" %}{% endblock %}

{% block content %}

<div class="container">
  <div class="row">
    <div class="col-md-8 mt-3 offset-md-2">
      <h3>{% trans "Sign In" %}</h3>

      <p>{% blocktrans %} $$$ This is debug text that DOES DISPLAY $$$$$$ Welcome back to the code|star blog. To leave a comment or like a post, please log in. If you
        have not created an account yet, then <a class="link" href="{{ signup_url }}">sign up</a>
        first.{% endblocktrans %}</p>
    </div>
  </div>
  <div class="row">
    <div class="col-md-8 mt-3 offset-md-2">
      <form class="login" method="POST" action="{% url 'account_login' %}">
        {% csrf_token %}
        {{ form.as_p }}
        {% if redirect_field_value %}
        <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
        {% endif %}
        <button class="btn btn-signup right" type="submit">{% trans "Sign In" %}</button>
      </form>
    </div>
  </div>
</div>
{% endblock %}

password_change.html代码

{% extends "account/base_manage_password.html" %}
{% load allauth i18n %}
{% block head_title %}
    {% trans "Change Password" %}
{% endblock head_title %}
{% block content %}
    {% element h1 %}
        {% trans "Change Password" %}
    {% endelement %}
    {% url 'account_change_password' as action_url %}
    {% element form form=form method="post" action=action_url %}
        {% slot body %}
            {% csrf_token %}
            {% element fields form=form %}
            {% endelement %}
        {% endslot %}
        {% slot actions %}
            {% element button type="submit" %}
                {% trans "Change Password" %}
            {% endelement %}
            <!-- <a href="{% url 'account_reset_password' %}">{% trans "Forgot Password? TESTHERE" %}</a> -->
        {% endslot %}
    {% endelement %}
{% endblock content %}

Settings中TEMPLATES配置

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, "templates"),
            os.path.join(BASE_DIR, "templates", "allauth"),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

内容的提问来源于stack exchange,提问作者Laurie Crean

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 00:06:08