Frage

I'm writing a little shortcut function to basically do the same thing as direct_to_template for sending email:

from django.template import Context, loader, Template

def direct_to_email(to, subject, from_email, template_name, parameters):
    parameters = {} if parameters is None else parameters

    template = loader.get_template(template_name)
    context = Context(parameters)

    body = template.render(context)
    # ...etc.

How can I get my TEMPLATE_CONTEXT_PROCESSORS to process this, too?

War es hilfreich?

Lösung

render_to_string() does that trick.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top