1
I’m assuming that obj.plain and obj.html are strings representing your templates (as stored in the database)?
If that is the case, then you still need to render your email content. However, instead of using render_to_string
, which takes as it’s first argument a template path, you will want to create a template based on your string, and then render that template. Consider something like the following:
...
from django.template import Context, Template
plain_template = Template(obj.plain)
context = Context({'name':variableWithSomeValue,'email':otherVariable})
email_context = plain_template.render(context)
...
send_email(...)
Here’s a link that better explains rendering string templates, as opposed to rendering template files.
https://docs.djangoproject.com/en/1.7/ref/templates/api/#rendering-a-context
Source:stackexchange.com