Closed archatas closed 1 year ago
@archatas for your case you just can use caching e.g. {% cache %}
the template tag https://docs.djangoproject.com/en/4.1/topics/cache/#template-fragment-caching.
Note, that you cannot render MJML until django-template is rendered inside the MJML-tag.
Rendering templates by a template tag every time the mjml template is accessed might require too much computing power or network bandwidth, especially, if you are trying to send a mass email referring each user personally.
My proposal is to add a management command that goes through the template folder and searches for .mjml files with whatever Django template variables and template tags. Then the command would render .html template files with the same template variables and template tags and place them in the same folders.
Django email sending commands could use those Django HTML templates to send emails, whereas the mjml conversion would happen only when there are changes in the template structure.