Created
April 1, 2017 02:36
-
-
Save andresmachado/62af11437035f5f4da79aafd75ac38b0 to your computer and use it in GitHub Desktop.
nested_serializer.py
This file contains 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
class ItemSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = Item | |
fields = ( | |
'field1', | |
'field2' | |
) | |
class CategorySerializer(serializers.ModelSerializer): | |
items = ItemSerializer(many=True, read_only=True) | |
class Meta: | |
model = Category | |
fields = ('field1', 'items', 'field2') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment