template.response.TemplateResponse

class TemplateResponse [source] TemplateResponse is a subclass of SimpleTemplateResponse that knows about the current HttpRequest.

template.response.SimpleTemplateResponse.__init__()

SimpleTemplateResponse.__init__(template, context=None, content_type=None, status=None, charset=None, using=None) [source] Instantiates a SimpleTemplateResponse object with the given template, context, content type, HTTP status, and charset. template A backend-dependent template object (such as those returned by get_template()), the name of a template, or a list of template names. context A dict of values to add to the template context. By default, this is an empty dictionary. content_t

template.response.SimpleTemplateResponse.template_name

SimpleTemplateResponse.template_name The name of the template to be rendered. Accepts a backend-dependent template object (such as those returned by get_template()), the name of a template, or a list of template names. Example: ['foo.html', 'path/to/bar.html']

template.response.SimpleTemplateResponse.resolve_template()

SimpleTemplateResponse.resolve_template(template) [source] Resolves the template instance to use for rendering. Accepts a backend-dependent template object (such as those returned by get_template()), the name of a template, or a list of template names. Returns the backend-dependent template object instance to be rendered. Override this method in order to customize template loading.

template.response.SimpleTemplateResponse.resolve_context()

SimpleTemplateResponse.resolve_context(context) [source] Preprocesses context data that will be used for rendering a template. Accepts a dict of context data. By default, returns the same dict. Override this method in order to customize the context.

template.response.SimpleTemplateResponse.rendered_content

SimpleTemplateResponse.rendered_content The current rendered value of the response content, using the current template and context data.

template.response.SimpleTemplateResponse.render()

SimpleTemplateResponse.render() [source] Sets response.content to the result obtained by SimpleTemplateResponse.rendered_content, runs all post-rendering callbacks, and returns the resulting response object. render() will only have an effect the first time it is called. On subsequent calls, it will return the result obtained from the first call.

template.response.SimpleTemplateResponse.is_rendered

SimpleTemplateResponse.is_rendered A boolean indicating whether the response content has been rendered.

template.response.SimpleTemplateResponse.context_data

SimpleTemplateResponse.context_data The context data to be used when rendering the template. It must be a dict. Example: {'foo': 123}

template.response.SimpleTemplateResponse.add_post_render_callback()

SimpleTemplateResponse.add_post_render_callback() [source] Add a callback that will be invoked after rendering has taken place. This hook can be used to defer certain processing operations (such as caching) until after rendering has occurred. If the SimpleTemplateResponse has already been rendered, the callback will be invoked immediately. When called, callbacks will be passed a single argument – the rendered SimpleTemplateResponse instance. If the callback returns a value that is not None,