This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

django-template-email provides a set of tools that allows you to easily build plain-text or HTML emails using templates.


After installing django-templatee-email, add template_email to your INSTALLED_APPS in


An email template is like any other django template. To use the template as an email, however, you must load the “email” templatetag library and use its tags to define the different parts of the email. The email templatetag library gives you three different tags to use: subject, body, and bodyhtml, each with their respective endsubject, endbody, and endbodyhtml.

For example

{% load email %}
{% subject %}Thank you for signing up!{% endsubject %}
{% body %}
Hello, {{ first_name }}.

Thank you for signing up. To find out more information, please visit

The Team
{% endbody %}
{% bodyhtml %}
Hello, <em>{{ first_name }}</em>.

Thank you for signing up.  To find out more information, click
<a href="">here</a>.
{% endbodyhtml %}

Each tag is entirely optional. You can set any part of the email as you normally would with Djanog’s EmailMessage class.

Sending Email

The TemplateEmail class is a subclass of django.core.mail.EmailMultiAlternatives, which itself is a subclass of django.core.mail.EmailMessage.

To send your email template as an email, simply instantiate the TemplateEmail class while passing it your template and (optionally) a context dict:

from template_email import TemplateEmail

context = {'first_name': user.first_name}
email = TemplateEmail(template='email/confirmation_message.html', context)

TemplateEmail Class

Of course, you may also extend the TemplateEmail class to suit your needs. The TemplateEmail class is initialized with optional keyword arguments of template and context. However, template and context variables may be overridden as a property as well. The TemplateEmail class has the following properties:

  • template: The template used to render the email
  • context: The context provided to the template
  • subject: The subject of the email
  • body: The plan-text body of the email
  • html: The html to attach as an alternative type

The subject, body, and html properties are intended as defaults, and will be overridden by whatever is given in the template.

When you call the send() method, the TemplateEmail class first renders the given template into the different parts of the email. The templatetags simply dump their contents into temporary context variables for the render() method use. The render method then renders the contents of each tag separately into the class’s subject, body, and bodyhtml properties.

As a convienience, the send() method will automatically convert User model instances to email recipients, formatting them as “first_name last_name <email>”.

Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-template-email-0.1.tar.gz (3.7 kB) Copy SHA256 Checksum SHA256 Source Dec 15, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting