Skip to main content

render_to_string

Load a template and render it with a context. Return a string.

template_name may be a string or a list of strings.

def render_to_string(
template_name: string|list,
context: dict = None,
request: HttpRequest = None,
using: string = None
) - > string

Load a template and render it with a context. Return a string.

Parameters

NameTypeDescription
template_name`stringlist`
contextdict = NoneA dictionary of values to be used as variables within the template during rendering.
requestHttpRequest = NoneAn optional current request object used to provide additional context processors.
usingstring = NoneThe name of the specific template engine backend to use for loading the template.

Returns

TypeDescription
stringThe rendered content of the template as a string.