From 3db88778893579e1d7609b584ef35409c8aa5a22 Mon Sep 17 00:00:00 2001 From: Adrian Coveney Date: Wed, 25 Jul 2018 10:53:43 +0100 Subject: [PATCH] Clarify documentation for TemplateHTMLRenderer Clarify that the response from a view may need to be modified to provide TemplateHTMLRenderer with a dict for it to use. --- docs/api-guide/renderers.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/api-guide/renderers.md b/docs/api-guide/renderers.md index ca3a29b82..954fb3bb9 100644 --- a/docs/api-guide/renderers.md +++ b/docs/api-guide/renderers.md @@ -103,6 +103,16 @@ Unlike other renderers, the data passed to the `Response` does not need to be se The TemplateHTMLRenderer will create a `RequestContext`, using the `response.data` as the context dict, and determine a template name to use to render the context. +--- + +**Note:** When used with a view that makes use of a serializer the `Response` sent for rendering may not be a dictionay and will need to be wrapped in a dict before returning to allow the TemplateHTMLRenderer to render it. For example: + +``` +response.data = {'results': response.data} +``` + +--- + The template name is determined by (in order of preference): 1. An explicit `template_name` argument passed to the response.