Use MJML in your Django templates. A very small and fast implementation.
This package leverages MRML, a Rust implementation of MJML using bindings provided by mjml-python.
If you want to run MJML itself as a separate HTTP server endpoint for conversion, use django-mjml instead. It uses the same mjml template tag.
From the documentation of the project:
MJML is a markup language designed to reduce the pain of coding a responsive email. Its semantic syntax makes it easy and straightforward and its rich standard components library speeds up your development time and lightens your email codebase. MJML’s open-source engine generates high quality responsive HTML compliant with best practices.
- Python >= 3.7
- Django >= 1.11
To install the package, run the following command:
pip install django-mjml-templateThen update your settings.py:
INSTALLED_APPS = (
...
'django_mjml_template',
)Load mjml in your django template and use mjml tag that will compile MJML to HTML:
{% load mjml %}
{% mjml %}
<mjml>
<mj-body>
<mj-section>
<mj-column>
<mj-text>Hello {{ user_name }}!</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
{% endmjml %}Contributions, bug reports, and suggestions are welcome! Feel free to open an issue or submit a pull request.