0π
I implemented something similar, hereβs what I did:
- Create an app, and registered a model to store the email
- Set up a management command to process the email
- Manage the cron job via django-chronograph
Rendering the email, I used render_to_string, for example
from django.template.loader import render_to_string
from myproject.myemailapp.models import EmailTpl
email_tpl = EmailTpl.objects.get(...#criteria here)
# fetch the rest of your dynamic variables
rendered_tpl = render_to_string(email_tpl.user_entered_tpl, {
"user": user,
"cooking_class": cooking_class,
# ... and so on
})
Alternatively, Django Packages has some packages you might want to look into. Would be great if you post back the route you decided.
π€Kenny Shen
0π
The plugin django-dbtemplates allows you to store templates in your database, and you can expose the dbtemplate app on your Admin site to edit. You can set your middleware settings such that either the database template or the same template in other locations has priority for loading.
We are using this in a project to manage templates for different products, with the database-stored template for each product linked by ForeignKey.
π€JessieinAg
- [Django]-How use python-docx to stream a file from template
- [Django]-Force re-collectstatic with django static?
Source:stackexchange.com