Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django serialize foreign key, django serializer foreign key

class ItemSerializer(serializers.ModelSerializer):
    category_name = serializers.CharField(source='category.name')

    class Meta:
        model = Item
        fields = ('id', 'name', 'category_name')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #serialize #foreign #django #serializer #foreign #key
ADD COMMENT
Topic
Name
7+4 =