Skip to content

Commit 90c9968

Browse files
committed
tutorial encode#1 incorrectly showed string of json instead of ReturnDict type from 'serializer.data', and also has a third item in the second usage
1 parent 221a28f commit 90c9968

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/tutorial/1-serialization.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ We've now got a few snippet instances to play with. Let's take a look at serial
151151

152152
serializer = SnippetSerializer(snippet)
153153
serializer.data
154-
# {'pk': 2, 'title': u'', 'code': u'print "hello, world"\n', 'linenos': False, 'language': u'python', 'style': u'friendly'}
154+
# ReturnDict([('pk', 2), ('title', u''), ('code', u'print "hello, world"\n'), ('linenos', False), ('language', 'python'), ('style', 'friendly')])
155155

156156
At this point we've translated the model instance into Python native datatypes. To finalize the serialization process we render the data into `json`.
157157

@@ -182,7 +182,8 @@ We can also serialize querysets instead of model instances. To do so we simply
182182

183183
serializer = SnippetSerializer(Snippet.objects.all(), many=True)
184184
serializer.data
185-
# [{'pk': 1, 'title': u'', 'code': u'foo = "bar"\n', 'linenos': False, 'language': u'python', 'style': u'friendly'}, {'pk': 2, 'title': u'', 'code': u'print "hello, world"\n', 'linenos': False, 'language': u'python', 'style': u'friendly'}]
185+
# [OrderedDict([('pk', 1), ('title', u''), ('code', u'foo = "bar"\n'), ('linenos', False), ('language', 'python'), ('style', 'friendly')]), OrderedDict([('pk', 2), ('title', u''), ('code', u'print "hello, world"\n'), ('linenos', False), ('language', 'python'), ('style', 'friendly')]), OrderedDict([('pk', 3), ('title', u''), ('code', u'print "hello, world"\n'), ('linenos', False), ('language', 'python'), ('style', 'friendly')])]
186+
186187

187188
## Using ModelSerializers
188189

0 commit comments

Comments
 (0)