Django Templated Email is a tool which sends email in django with html/txt templates.
Features:
- Html / Txt templates
- Context variables
- Current site (from sites framework) available in templates as {{ site }} variable
Installation and usage:
Run the following command inside your django’s project directory
1 2 3 |
git submodule add https://github.com/simion/django-templated-email.git templated_email |
In setting.py file add “templated_email” to INSTALLED_APPS
1 2 3 4 5 6 7 |
INSTALLED_APPS = ( ... 'templated_email', ... ) |
Use the function. Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from templated_email import send_templated_email ... send_templated_email( "Example subject" None, 'example-template', context, # context variables to send in template # cc = [] # bcc = [] ) |
Don’t forget to create the template files.
In your templates folder, create a folder named ‘email_templates’.
Place example-template.html or example-template.txt inside of it.
Example:
1 2 3 |
<project-path>/<app-path>/templates/email_templates/exmaple-template.html |