Answer the question
In order to leave comments, you need to log in
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
from django.template.response import SimpleTemplateResponse
htmlmessage = SimpleTemplateResponse('template_name.html', {'context': context})
rendered_data = htmlmessage.rendered_content
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question