Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Last active September 3, 2020 10:03
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 velotiotech/f488aa2244f73ec8032bd323e6b7417e to your computer and use it in GitHub Desktop.
Save velotiotech/f488aa2244f73ec8032bd323e6b7417e to your computer and use it in GitHub Desktop.
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