From e6fd79fd88067d830886f9c463d5b9e5c13d7ce3 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 21 Dec 2013 17:18:57 +0000 Subject: Latest docs build --- tutorial/1-serialization.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tutorial') 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"}'

Deserialization is similar. First we parse a stream into Python native datatypes...

-
import StringIO
+
# 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)
 

...then we restore those native datatypes into to a fully populated object instance.

-- cgit v1.2.3