aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/renderers.md
diff options
context:
space:
mode:
authorTom Christie2012-10-05 13:04:34 +0100
committerTom Christie2012-10-05 13:04:34 +0100
commit2575ea92aad3608142cfdd3ede5ee1b53e2064ba (patch)
treea2ef3c34b022c585981378f4d9f4461445d39b03 /docs/api-guide/renderers.md
parent26c7d6df6c0a12a2e19e07951b93de80bbfdf91c (diff)
downloaddjango-rest-framework-2575ea92aad3608142cfdd3ede5ee1b53e2064ba.tar.bz2
Docs for template responses
Diffstat (limited to 'docs/api-guide/renderers.md')
-rw-r--r--docs/api-guide/renderers.md19
1 files changed, 18 insertions, 1 deletions
diff --git a/docs/api-guide/renderers.md b/docs/api-guide/renderers.md
index ef0ed46f..d2d8985d 100644
--- a/docs/api-guide/renderers.md
+++ b/docs/api-guide/renderers.md
@@ -86,11 +86,28 @@ If your API includes views that can serve both regular webpages and API response
## DocumentingHTMLRenderer
+Renders data into HTML for the browseable API. This renderer will determine which other renderer would have been given highest priority, and use that to display an API style response within the HTML page.
+
**.media_type:** `text/html`
**.format:** `'.api'`
-## TemplateHTMLRenderer
+## HTMLTemplateRenderer
+
+Renders data to HTML, using Django's standard template rendering.
+Unlike other renderers, the data passed to the `Response` does not need to be serialized. Also, unlike other renderers, you may want to include a `template_name` argument when creating the `Response`.
+
+The HTMLTemplateRenderer will create a `RequestContext`, using the `response.data` as the context dict, and determine a template name to use to render the context.
+
+The template name is determined by (in order of preference):
+
+1. An explicit `.template_name` attribute set on the response.
+2. An explicit `.template_name` attribute set on this class.
+3. The return result of calling `view.get_template_names()`.
+
+You can use `HTMLTemplateRenderer` either to return regular HTML pages using REST framework, or to return both HTML and API responses from a single endpoint.
+
+If you're building websites that use `HTMLTemplateRenderer` along with other renderer classes, you should consider listing `HTMLTemplateRenderer` as the first class in the `renderer_classes` list, so that it will be prioritised first even for browsers that send poorly formed ACCEPT headers.
**.media_type:** `text/html`