Skip to main content

stream_template

Render a template by name with the given context as a stream. This returns an iterator of strings, which can be used as a streaming response from a view.

def stream_template(
template_name_or_list: str | Template | list[str | Template],
context: Any
) - > Iterator[str]

Render a template by name with the given context as a stream. This returns an iterator of strings, which can be used as a streaming response from a view.

Parameters

NameTypeDescription
template_name_or_list`strTemplate
contextAnyThe variables to make available in the template.

Returns

TypeDescription
Iterator[str]An iterator of strings representing the rendered template content, suitable for streaming responses.