简体   繁体   中英

Can't override Django's email subject line

I have a registration folder in my Django app, and I'm using django.contrib.auth.views for all the user log in and registration things. Anyway, I set up my password_reset_form.html and everything works well, except I can't seem to set the email subject line.

Every resource I'm finding online says I can just add password_reset_subject.txt to my registration folder (on the same level as all my user html templates), and that should override the django default. However, that's not working. I would be willing to switch to the send_mail() approach but I like how the built in django.auth one sends a tokened link to change_password.

Is there any reason my password_reset_subject.txt would be ignored? Thanks in advance.

I have Django 1.11 and my setup is as follows:

Template:

- Template Directory
-- registration
---- password_reset_subject.txt
-- admin
--- admin_override_templates
...

Urls:

url(r'^password/', include('django.contrib.auth.urls')),

Console Output( 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     |  -------------------------------------------------------------------------------

And it seems to work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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