我的Django应用中有一个注册文件夹,所有用户登录和注册时都使用django.contrib.auth.views
。无论如何,我设置了password_reset_form.html
,并且一切正常,但似乎无法设置电子邮件主题行。
我在网上找到的所有资源都说我可以只将password_reset_subject.txt
添加到我的registration
文件夹中(与所有用户html模板处于同一级别),这应该覆盖django的默认值。但是,这不起作用。我愿意切换到send_mail()
方法,但是我喜欢内置的django.auth如何将标记链接发送到change_password。
我的password_reset_subject.txt
是否有任何理由会被忽略?
预先感谢。
答案 0 :(得分:0)
我有Django 1.11,我的设置如下:
模板:
- Template Directory
-- registration
---- password_reset_subject.txt
-- admin
--- admin_override_templates
...
网址:
url(r'^password/', include('django.contrib.auth.urls')),
控制台输出(for email console backend):
dz01 | -------------------------------------------------------------------------------
dz01 | Content-Type: text/plain; charset="utf-8"
dz01 | MIME-Version: 1.0
dz01 | Content-Transfer-Encoding: 7bit
dz01 | Subject: Dummy Subject Text <--- My dummy Subject
dz01 | From: webmaster@localhost
dz01 | To: admin@aa.cc
dz01 | Date: Wed, 07 Nov 2018 02:52:50 -0000
dz01 | Message-ID: <20181107025250.19.86917@19eb871251bb>
dz01 |
dz01 |
dz01 | You're receiving this email because you requested a password reset for your user account at web.
dz01 |
dz01 | Please go to the following page and choose a new password:
dz01 |
dz01 | http://web/password/reset/MQ/513-b49b4815f6d258b8c1a5/
dz01 |
dz01 | Your username, in case you've forgotten: admin
dz01 |
dz01 | Thanks for using our site!
dz01 |
dz01 | The web team
dz01 |
dz01 |
dz01 |
dz01 | -------------------------------------------------------------------------------
它似乎工作正常。