aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/renderers.md
diff options
context:
space:
mode:
authorTom Christie2012-10-10 12:15:18 +0100
committerTom Christie2012-10-10 12:15:18 +0100
commit648d2be29b0738999742f4d844caab7b7652d1ad (patch)
treeaa4b8a630231f06477e2356abcfee80d54d2c8d8 /docs/api-guide/renderers.md
parentccd2b0117d9c26199b1862a302b1eb06dd2f07b2 (diff)
downloaddjango-rest-framework-648d2be29b0738999742f4d844caab7b7652d1ad.tar.bz2
Make sure JSON output in Browseable API is nicely indented
Diffstat (limited to 'docs/api-guide/renderers.md')
-rw-r--r--docs/api-guide/renderers.md19
1 files changed, 17 insertions, 2 deletions
diff --git a/docs/api-guide/renderers.md b/docs/api-guide/renderers.md
index 1b266f7e..b2ebd0c7 100644
--- a/docs/api-guide/renderers.md
+++ b/docs/api-guide/renderers.md
@@ -132,7 +132,7 @@ Renders data into HTML for the Browseable API. This renderer will determine whi
## Custom renderers
-To implement a custom renderer, you should override `BaseRenderer`, set the `.media_type` and `.format` properties, and implement the `.render(self, data, media_type)` method.
+To implement a custom renderer, you should override `BaseRenderer`, set the `.media_type` and `.format` properties, and implement the `.render(self, data, media_type=None, renderer_context=None)` method.
For example:
@@ -144,11 +144,26 @@ For example:
media_type = 'text/plain'
format = 'txt'
- def render(self, data, media_type):
+ def render(self, data, media_type=None, renderer_context=None):
if isinstance(data, basestring):
return data
return smart_unicode(data)
+The arguments passed to the `.render()` method are:
+
+#### `data`
+
+The request data, as set by the `Response()` instantiation.
+
+#### `media_type=None`
+
+Optional. If provided, this is the accepted media type, as determined by the content negotiation stage. Depending on the client's `Accept:` header, this may be more specific than the renderer's `media_type` attribute, and may include media type parameters. For example `"application/json; nested=true"`.
+
+#### `renderer_context=None`
+
+Optional. If provided, this is a dictionary of contextual information provided by the view.
+By default this will include the following keys: `view`, `request`, `response`, `args`, `kwargs`.
+
---
# Advanced renderer usage