Skip to content

Instantly share code, notes, and snippets.

@tomchristie
Created March 28, 2013 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomchristie/5262680 to your computer and use it in GitHub Desktop.
Save tomchristie/5262680 to your computer and use it in GitHub Desktop.
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'}
@tomchristie
Copy link
Author

Would be read-only tho'

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