mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 08:14:16 +03:00
Fix custom parser example
This commit is contained in:
parent
c091addb83
commit
f161241e07
|
@ -144,17 +144,16 @@ By default this will include the following keys: `view`, `request`, `args`, `kwa
|
||||||
The following is an example plaintext parser that will populate the `request.data` property with a string representing the body of the request.
|
The following is an example plaintext parser that will populate the `request.data` property with a string representing the body of the request.
|
||||||
|
|
||||||
class PlainTextParser(BaseParser):
|
class PlainTextParser(BaseParser):
|
||||||
"""
|
|
||||||
Plain text parser.
|
|
||||||
"""
|
|
||||||
|
|
||||||
media_type = 'text/plain'
|
|
||||||
|
|
||||||
def parse(self, stream, media_type=None, parser_context=None):
|
|
||||||
"""
|
"""
|
||||||
Simply return a string representing the body of the request.
|
Plain text parser.
|
||||||
"""
|
"""
|
||||||
return stream.read()
|
media_type = 'text/plain'
|
||||||
|
|
||||||
|
def parse(self, stream, media_type=None, parser_context=None):
|
||||||
|
"""
|
||||||
|
Simply return a string representing the body of the request.
|
||||||
|
"""
|
||||||
|
return stream.read()
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user