-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Small fixes to the tutorial #2460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…Dict type from 'serializer.data', and also has a third item in the second usage
…n for format suffixes
…torial/settings.py'
We've now fixed (in master the representation of ReturnList / ReturnDict to simply return the native dict/list - since they should really just be transparent implementation details for the most part. I'd also prefer dropping the |
Happy to accept this if updated as noted above, but closing in the meantime. |
Sorry for the slow response to this. Making the changes now. I replaced what I had changed to ReturnDict back to a regular dict. I'm a little confused as to what you want me to do for the references to OrderedDict. There's one in the section Thanks! |
Hey @tomchristie -- happy to make the changes for you, I'm just a bit confused on what you're hoping for. Thanks for the help! |
@@ -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.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')])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave this as a dict - I know it's not exactly correct, but it's more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomchristie Gotcha -- makes sense. Thank you! I also added a 3rd element that's a duplicate of the 2nd because there's an extra call to serializer.save()
on line 176. Would you prefer I just leave the first two? Another one of those cases where it's not exactly correct with just the 2, but probably more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't understand that. Which 3rd element? Which 2nd element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomchristie On line 148, you save the snippet with "Hello world". You then serialize it and resave the "Hello world" snippet on line 176. So the item with pk 2 is "Hello world", and there's also an item with pk 3 that's "Hello world" from the second save.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever you think it most sensible.
@mmarvick - There ya go - those two inline comments. |
@tomchristie I've made the edits and committed. I don't see them here -- I assume it's because the PR is marked as closed? I'm still learning my ways around Github, so let me know if there's something I need to do. They're on the master branch of my fork. |
@tomchristie Cool. Should be ready to merge. |
Looks good to me. Thanks @mmarvick! |
Fixed a couple of small errata I noticed when going through the tutorial.