Django 3 一直使用管理模板进行电子邮件重置

问题描述

我尝试关注有关此主题的其他帖子,但到目前为止没有任何效果。通常其他帖子是关于 Django 1 的。

出于某种原因,Django 一直忽略 password_reset_email.html 文件。我在使用的同一文件夹 (./myapp/templates/registration/password_reset_email.html) 中有一个 login.html,但 password_reset 文件被忽略。

我尝试了模板文件夹的不同位置。

尝试在 URL 模式中提供路径:

    path('accounts/password_reset/',auth_views.PasswordResetView.as_view(html_email_template_name='registration/password_reset.html')),

或者只是

    path('accounts/',include('django.contrib.auth.urls')),

尝试相应地设置设置:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates','Dirs': [os.path.join(BASE_DIR,'omics_server','templates'),os.path.join(BASE_DIR,'pipelines',],'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',},]

但是没有任何效果。模板如下所示:

{% extends 'base.html' %}

{% block title %}Forgot Your Password?{% endblock %}

{% block content %}
  <h1>Forgot your password?</h1>
  <p>Enter your email address below,and we'll email instructions for setting a new one.</p>

  <form method="POST">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Send me instructions!">
  </form>
{% endblock %}

我不明白为什么 templates/registration/login.html 有效,但其他文件无效。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)