Skip to content

Commit 3db8877

Browse files
tofu-rocketryxordoquy
authored andcommitted
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.
1 parent 8351747 commit 3db8877

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/api-guide/renderers.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ Unlike other renderers, the data passed to the `Response` does not need to be se
103103

104104
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.
105105

106+
---
107+
108+
**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:
109+
110+
```
111+
response.data = {'results': response.data}
112+
```
113+
114+
---
115+
106116
The template name is determined by (in order of preference):
107117

108118
1. An explicit `template_name` argument passed to the response.

0 commit comments

Comments
 (0)