Reputation: 49
I want to email
a template in django. The template has one variable say name
. I want to filled this value. How to do that. context is not working because i don't need to render the page.
Upvotes: 0
Views: 193
Reputation: 43136
Try this
from django.template.loader import render_to_string
text = render_to_string('my_template.html', { 'name': 'xxx' })
Upvotes: 0
Reputation: 87185
context is not working because i don't need to render the page.
I guess what you are looking for is render_to_string shortcut.
Upvotes: 0
Reputation: 599926
Of course you need to render the template - and you do that via the context. How is it not working?
Upvotes: 1