'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!
Solution 1:[1]
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.
Solution 2:[2]
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 %}
Solution 3:[3]
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 %}
Solution 4:[4]
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')
Solution 5:[5]
- For me the default behavior was to have the template in the the project folder and not in the particular apps directory
api_project/templates/account/email/email_confirmation_subject.txt! - For anybody that might be here just because [example.com] still appears at the subject even when they customized successfully the
templates/account/email/email_confirmation_subject.txta variable that you need to configure and it's not quit obvious it'sACCOUNT_EMAIL_SUBJECT_PREFIX = '[example.com]'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | heber camargo |
| Solution 2 | Ashish Sondagar |
| Solution 3 | noob |
| Solution 4 | rportron |
| Solution 5 | Nikos |
