Django emails with html/txt templates

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
git submodule add https://github.com/simion/django-templated-email.git templated_email

  

In setting.py file add "templated_email" to INSTALLED_APPS

INSTALLED_APPS = (
...
'templated_email',
...
)


Use the function. Example:

from templated_email import send_templated_email

...

send_templated_email(
"Example subject"
None,
['test@email.com'] #must be a list or tuple
'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:

 <project-path>/<app-path>/templates/email_templates/exmaple-template.html


 

Comments

Popular posts from this blog

PIP - upgrade all packages from requirements.txt (interactively)

Improve font rendering for IntelliJ IDEA / Pycharm in Ubuntu