A
A
Artyom Innokentiev2015-12-27 20:24:36
Django
Artyom Innokentiev, 2015-12-27 20:24:36

How to render template but not send HttpResponse (Django)?

I want to put the body of the letter in a separate template with variables and add it when sending the letter - how to render it with the passed context, but not send HttpResponse?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artyom Innokentiev, 2015-12-27
@artinnok

from django.template.response import SimpleTemplateResponse
htmlmessage = SimpleTemplateResponse('template_name.html', {'context': context})
rendered_data = htmlmessage.rendered_content

V
Vlad Feninets, 2015-12-27
@fnnzzz

use extends and pass parameters there in blocks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question