aboutsummaryrefslogtreecommitdiffstats
path: root/tutorial
diff options
context:
space:
mode:
authorTom Christie2013-12-21 17:18:57 +0000
committerTom Christie2013-12-21 17:18:57 +0000
commite6fd79fd88067d830886f9c463d5b9e5c13d7ce3 (patch)
treebe963ffadab55cdad970ff11e79c8bf25580c18d /tutorial
parent480b64d3138f4b37dc1cbce7202573fb1f94f2a6 (diff)
downloaddjango-rest-framework-e6fd79fd88067d830886f9c463d5b9e5c13d7ce3.tar.bz2
Latest docs build
Diffstat (limited to 'tutorial')
-rw-r--r--tutorial/1-serialization.html6
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>