简体   繁体   中英

Django Allauth: How to customize confirmation email subject?

I was able to customize the confirmation email HTML template by adding this file into the templates folder:

templates/account/email/email_confirmation_signup_message.html

Now I'm trying to customize the subject of the email by adding the text I want inside this file:

templates/account/email/email_confirmation_signup_subject.txt

But it doesn't seem to do anything, I still get the default subject all the time.

Does anyone know what I'm doing wrong?

Many thanks!

Do in this way...

  • install django-mail-templated

  • base template file code...

{{ TAG_START_SUBJECT }}
{% autoescape off %}
{% block subject %}
{% endblock %}
{% endautoescape %}
{{ TAG_END_SUBJECT }}

  • main template file code...
{% block subject %}
Hello User..
{% endblock %}

Change file name to this:- templates/account/email/email_confirmation_subject.txt and inside write

{% load i18n %}
{% autoescape off %}
{% blocktrans %}Please Confirm Your E-mail Address or do whatever..{% endblocktrans %}
{% endautoescape %}

Maybe the problem comes with your urls.py file You need to indicate here the file you use to customize the subject of your email.

PasswordResetView.as_view(template_name='email_confirmation_signup_message.html', subject_template_name='email_confirmation_signup_subject.txt')

You have to add this two files... first: account/email/email_confirmation_signup_message.html

{% include "account/email/email_confirmation_message.html" %}

second:

account/email/email_confirmation_message.html

The template that you want.

and finally delete the two.txt file: account/email/email_confirmation_signup_message.txt account/email/email_confirmation_message.txt

pd: if you copy the folder template/account from your virtual enviroment you have to delete the files over there as well.

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