Commit 90c9968a by Michael Marvick

tutorial #1 incorrectly showed string of json instead of ReturnDict type from…

tutorial #1 incorrectly showed string of json instead of ReturnDict type from 'serializer.data', and also has a third item in the second usage
parent 221a28ff
...@@ -151,7 +151,7 @@ We've now got a few snippet instances to play with. Let's take a look at serial ...@@ -151,7 +151,7 @@ We've now got a few snippet instances to play with. Let's take a look at serial
serializer = SnippetSerializer(snippet) serializer = SnippetSerializer(snippet)
serializer.data serializer.data
# {'pk': 2, 'title': u'', 'code': u'print "hello, world"\n', 'linenos': False, 'language': u'python', 'style': u'friendly'} # ReturnDict([('pk', 2), ('title', u''), ('code', u'print "hello, world"\n'), ('linenos', False), ('language', 'python'), ('style', 'friendly')])
At this point we've translated the model instance into Python native datatypes. To finalize the serialization process we render the data into `json`. At this point we've translated the model instance into Python native datatypes. To finalize the serialization process we render the data into `json`.
...@@ -182,7 +182,8 @@ We can also serialize querysets instead of model instances. To do so we simply ...@@ -182,7 +182,8 @@ We can also serialize querysets instead of model instances. To do so we simply
serializer = SnippetSerializer(Snippet.objects.all(), many=True) serializer = SnippetSerializer(Snippet.objects.all(), many=True)
serializer.data serializer.data
# [{'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'}] # [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')])]
## Using ModelSerializers ## Using ModelSerializers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment