Reputation:
I want to pass "name" to html file and get the response instead of rendering the page. I want to send this html page via email after adding the "name".
<!DOCTYPE html>
<html>
<body>
<var>{{name}}</var>
</body>
</html>
Here is the django views code:
def sending(request):
-- passing request.user --
return_page = html_page(request.user)
send_email(--email content--)
Can someone suggest me how to do this?
Upvotes: 1
Views: 557
Reputation: 4643
You can use django render_to_string here.
Ex :
from django.template.loader import render_to_string
rendered = render_to_string('my_template.html', { 'foo': 'bar' })
Upvotes: 5