Skip to content
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

Add .validated_data in tutorial part 1. #2214

Closed
tomchristie opened this issue Dec 5, 2014 · 7 comments
Closed

Add .validated_data in tutorial part 1. #2214

tomchristie opened this issue Dec 5, 2014 · 7 comments

Comments

@tomchristie
Copy link
Member

We should add .validated_data here. Opening the issue as I've not had time to check what it would return, but wanted to make sure we track this...

serializer = SnippetSerializer(data=data)
serializer.is_valid()
# True
serializer.save()
# <Snippet: Snippet object>
@jpadilla
Copy link
Member

jpadilla commented Dec 5, 2014

>>> serializer = SnippetSerializer(data=data)
>>> serializer.is_valid()
True
>>> serializer.validated_data
OrderedDict([('title', ''), ('code', u'print "hello, world"\n'), ('linenos', False), ('language', 'python'), ('style', 'friendly')])
>>> serializer.save()
<Snippet: Snippet object>

@xordoquy
Copy link
Collaborator

xordoquy commented Dec 5, 2014

the output will be slightly different with py2: it'll be a {} instead of OrderedDict()

@jpadilla
Copy link
Member

jpadilla commented Dec 5, 2014

@xordoquy weird, I just tried that with python2.7

@xordoquy
Copy link
Collaborator

xordoquy commented Dec 5, 2014

a lot of things have changed with py3 ;)

@xordoquy
Copy link
Collaborator

xordoquy commented Dec 5, 2014

@jpadilla try {'a': 1}.keys() in python3 ;)

@jpadilla
Copy link
Member

jpadilla commented Dec 5, 2014

I think you might have meant py3 in #2214 (comment)

@jpadilla
Copy link
Member

jpadilla commented Dec 5, 2014

@xordoquy actually ran it again with python3.4 and got the same output for serializer.validated_data

>>> serializer.validated_data
OrderedDict([('title', ''), ('code', 'print "hello, world"\n'), ('linenos', False), ('language', 'python'), ('style', 'friendly')])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants