Created
May 1, 2022 12:04
-
-
Save antonioccneto/a88b77df0a5e95d83f4131726652fe35 to your computer and use it in GitHub Desktop.
Django Rest - Item aninhado
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
class SerializerDaFK(serializers.ModelSerializer): | |
""" Serializer com Fields Específicos """ | |
class Meta: | |
model = NomeDoModeldaFK | |
fields = ('id', | |
'campo1', | |
'campo2') | |
class SerializerPrincipal(serializers.ModelSerializer): | |
""" Serializer principal """ | |
field_fk = SerializerDaFK() | |
class Meta: | |
model = ModelPrincipal | |
fields = ('id', 'titulo', 'field_fk') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment