aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide
diff options
context:
space:
mode:
authorTom Christie2012-10-17 22:39:07 +0100
committerTom Christie2012-10-17 22:39:07 +0100
commitfb56f215ae50da0aebe99e05036ece259fd3e6f1 (patch)
tree1566a18e4b4ad03a094c2c630b57d1530a9245d7 /docs/api-guide
parent4231995fbd80e45991975ab81d9e570a9f4b72d0 (diff)
downloaddjango-rest-framework-fb56f215ae50da0aebe99e05036ece259fd3e6f1.tar.bz2
Added `media_type` to `.parse()` - Consistency with renderer API.
Diffstat (limited to 'docs/api-guide')
-rw-r--r--docs/api-guide/parsers.md10
1 files changed, 8 insertions, 2 deletions
diff --git a/docs/api-guide/parsers.md b/docs/api-guide/parsers.md
index 70abad9b..18a5872c 100644
--- a/docs/api-guide/parsers.md
+++ b/docs/api-guide/parsers.md
@@ -101,6 +101,12 @@ The arguments passed to `.parse()` are:
A stream-like object representing the body of the request.
+### media_type
+
+Optional. If provided, this is the media type of the incoming request.
+
+Depending on the request's `Content-Type:` header, this may be more specific than the renderer's `media_type` attribute, and may include media type parameters. For example `"text/plain; charset=utf-8"`.
+
### parser_context
Optional. If supplied, this argument will be a dictionary containing any additional context that may be required to parse the request content.
@@ -118,7 +124,7 @@ The following is an example plaintext parser that will populate the `request.DAT
media_type = 'text/plain'
- def parse(self, stream, parser_context=None):
+ def parse(self, stream, media_type=None, parser_context=None):
"""
Simply return a string representing the body of the request.
"""
@@ -135,7 +141,7 @@ For example:
A naive raw file upload parser.
"""
- def parse(self, stream, parser_context):
+ def parse(self, stream, media_type=None, parser_context=None):
content = stream.read()
name = 'example.dat'
content_type = 'application/octet-stream'