Created
March 28, 2013 12:14
-
-
Save tomchristie/5262680 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import serializers | |
stuff = {'name': 'toran', 'other_content': {'foo': 'things', 'bar': 'stuff'}} | |
class ExampleSerializer(serializers.Serializer): | |
name = serializers.Field() | |
foo = serializers.Field(source='other_content.foo') | |
bar = serializers.Field(source='other_content.bar') | |
serializer = ExampleSerializer(stuff) | |
print serializer.data | |
# {'name': u'toran', 'foo': u'things', 'bar': u'stuff'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would be read-only tho'