From 36f8588c96457c23e74638cddda49d4128056236 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 d547a7bbf..512fcb651 100644 --- a/docs/api-guide/renderers.md +++ b/docs/api-guide/renderers.md @@ -100,6 +100,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.