skillfed

django-premailer

Django template tag that turns CSS blocks into style attributes using premailer.

django-premailer v0.2.0 211.8K downloads/30d#9,471 on PyPI49
Permissive license MIT DORMANT released

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-premailer

uv

uv add django-premailer

poetry

poetry add django-premailer

Installing 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

Development Status :: 4 - BetaFramework :: DjangoFramework :: Django :: 1.6Framework :: Django :: 1.7Framework :: Django :: 1.8Framework :: Django :: 1.9Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: OS IndependentOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: CommunicationsTopic :: Internet :: WWW/HTTPTopic :: Other/Nonlisted TopicTopic :: Software Development :: Libraries :: Python Modules

Tags

django inline cssemail html stylingcss to style attributesdjango template premailerhtml email formattinginline styles djangocss inlining template tag
email-templatingdjango-extension

More Python Modules packages