django-premailer
Django template tag that turns CSS blocks into style attributes using premailer.
What it is and what it does
django-premailer is a Django template tag wrapper around the premailer library that converts CSS rules into inline style attributes on HTML elements. It is primarily designed for preparing HTML emails, where external stylesheets cannot be reliably loaded by mail clients. You load the tag in a template, wrap HTML content and CSS rules in the premailer block, and the tag outputs HTML with styles moved from the CSS block into inline style attributes on matching elements.
The package has no runtime dependencies and installs cleanly. However, it has been dormant since 2016 with no active maintenance, meaning it may not be tested or compatible with modern Django versions or Python releases. The underlying premailer library is a separate dependency that you will need to install separately to use this tag.
Use it for:
- Preparing transactional email templates in Django where inline CSS is required for consistent rendering across email clients
- Converting Django-templated HTML with CSS blocks into email-safe HTML for sending via SMTP
- Building email notification systems that need styled HTML without relying on external stylesheet delivery
- Inlining styles for HTML content that will be rendered in environments that strip external CSS links
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Django template tag that converts CSS blocks into inline style attributes on HTML elements, typically used to prepare HTML for email delivery where external stylesheets are not supported.
Yes, if you are using an older Django version (1.6–1.9 range) and need inline CSS for email templates. No, if you are on a modern Django release—the package is unmaintained since 2016 and classifiers only list support through Django 1.9 and Python 3.5. Consider alternatives or verify compatibility with your Django version before committing to this package.
Install
django-premailer on PyPI
pip
pip install django-premaileruv
uv add django-premailerpoetry
poetry add django-premailerInstalling django-premailer
Before you install
Installation is straightforward with no runtime dependencies. The package is dormant—last release was in 2016 and last commit in 2024—so it receives no active maintenance, though the repository remains public and unarchived.
License in practice
MIT license is permissive and poses no restrictions on use, modification, or distribution in commercial or private projects.
Quickstart
pip install django-premailer
# In settings.py, add to INSTALLED_APPS:
INSTALLED_APPS = (
'django_premailer',
)
# In template:
{% load premailer %}
{% premailer "http://example.com" %}
h1 { color: blue; }
{{ content }}
{% endpremailer %}
Verify before relying
- Whether the underlying premailer library is actively maintained and compatible with current Django versions
- Whether this package works reliably with modern Python versions beyond those listed in classifiers (3.5 and earlier)
- Current test coverage and whether the package has been tested against recent Django releases
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 3,707 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 211,839/month — #9,471 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_premailer-0.2.0-py2.py3-none-any.whl
Keywords: premailer, inline css, django, templatetag, html, lxml, email, mail, style
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
premailerConverts CSS style blocks into inline style…
permissive · top 5,000 on PyPI
css-inlineInlines CSS from style and link tags directly…
permissive · top 5,000 on PyPI
pynlinerConverts CSS stylesheets to inline styles in…
permissive · top 15,000 on PyPI
django-sekizaiDjango Sekizai provides template block…
permissive · top 15,000 on PyPI
django-compressorDjango Compressor combines, minifies, and…
permissive · top 5,000 on PyPI
django-templated-mailSends Django emails using template files…
permissive · top 15,000 on PyPI
djangocms-admin-styleProvides styled CSS templates and admin…
permissive · top 15,000 on PyPI
email-toWraps Python's standard email modules to…
permissive · top 15,000 on PyPI
emailsBuild and send HTML and plain-text emails with…
permissive · top 15,000 on PyPI
django-template-partialsProvides reusable named template partials for…
permissive · top 15,000 on PyPI