diff options
| author | Tom Christie | 2013-12-21 17:18:57 +0000 |
|---|---|---|
| committer | Tom Christie | 2013-12-21 17:18:57 +0000 |
| commit | e6fd79fd88067d830886f9c463d5b9e5c13d7ce3 (patch) | |
| tree | be963ffadab55cdad970ff11e79c8bf25580c18d /tutorial | |
| parent | 480b64d3138f4b37dc1cbce7202573fb1f94f2a6 (diff) | |
| download | django-rest-framework-e6fd79fd88067d830886f9c463d5b9e5c13d7ce3.tar.bz2 | |
Latest docs build
Diffstat (limited to 'tutorial')
| -rw-r--r-- | tutorial/1-serialization.html | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tutorial/1-serialization.html b/tutorial/1-serialization.html index 99923902..c75116d3 100644 --- a/tutorial/1-serialization.html +++ b/tutorial/1-serialization.html @@ -363,9 +363,11 @@ content # '{"pk": 2, "title": "", "code": "print \\"hello, world\\"\\n", "linenos": false, "language": "python", "style": "friendly"}' </code></pre> <p>Deserialization is similar. First we parse a stream into Python native datatypes... </p> -<pre class="prettyprint lang-py"><code>import StringIO +<pre class="prettyprint lang-py"><code># This import will use either `StringIO.StringIO` or `io.BytesIO` +# as appropriate, depending on if we're running Python 2 or Python 3. +from rest_framework.compat import BytesIO -stream = StringIO.StringIO(content) +stream = BytesIO(content) data = JSONParser().parse(stream) </code></pre> <p>...then we restore those native datatypes into to a fully populated object instance.</p> |
