aboutsummaryrefslogtreecommitdiffstats
path: root/docs/tutorial
diff options
context:
space:
mode:
authorTom Christie2012-10-17 14:42:16 -0700
committerTom Christie2012-10-17 14:42:16 -0700
commitbbd3728da615f688da6a5276c6a898990275f32c (patch)
tree1566a18e4b4ad03a094c2c630b57d1530a9245d7 /docs/tutorial
parent6717d654d0bbfdfca4aaea84a5b4814c4e5f7567 (diff)
parentfb56f215ae50da0aebe99e05036ece259fd3e6f1 (diff)
downloaddjango-rest-framework-bbd3728da615f688da6a5276c6a898990275f32c.tar.bz2
Merge pull request #303 from tomchristie/parser_refactor
Parser refactor
Diffstat (limited to 'docs/tutorial')
-rw-r--r--docs/tutorial/1-serialization.md7
1 files changed, 5 insertions, 2 deletions
diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md
index e21433ba..5b58f293 100644
--- a/docs/tutorial/1-serialization.md
+++ b/docs/tutorial/1-serialization.md
@@ -134,12 +134,15 @@ We've now got a few comment instances to play with. Let's take a look at serial
At this point we've translated the model instance into python native datatypes. To finalise the serialization process we render the data into `json`.
- stream = JSONRenderer().render(serializer.data)
- stream
+ content = JSONRenderer().render(serializer.data)
+ content
# '{"id": 1, "email": "leila@example.com", "content": "nothing to say", "created": "2012-08-22T16:20:09.822"}'
Deserialization is similar. First we parse a stream into python native datatypes...
+ import StringIO
+
+ stream = StringIO.StringIO(content)
data = JSONParser().parse(stream)
...then we restore those native datatypes into to a fully populated object instance.