Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django rest framework show ManyToManyField key value

class AlbumSerializer(serializers.ModelSerializer):
    tracks = serializers.StringRelatedField(many=True)

    class Meta:
        model = Album
        fields = ['album_name', 'artist', 'tracks']
        
https://www.django-rest-framework.org/api-guide/relations/#stringrelatedfield
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #rest #framework #show #ManyToManyField #key
ADD COMMENT
Topic
Name
2+3 =