Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Last active Sep 3, 2020
Embed
What would you like to do?
class AddressSerializer(serializers.ModelSerializer):
class Meta:
model = Address
fields = ("detail", "city")
class UserSerializer(serializers.ModelSerializer):
addresses = AddressSerializer(many=True, read_only=True)
class Meta:
model = User
fields = ("name", "email", "addresses")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment