"django rest framework - query limit on nested serializer?" Code Answer

class containerserializer(serializers.modelserializer):
    items = serializers.serializermethodfield()

    def get_items(self, obj):
        query = item.objects.filter(item_set__color='green')
        serializer = itemserializer(query, many=true)
        return serializer.data

    class meta:
        model = container
        fields = ('size', 'shape', 'items')
By Thibault Falise on April 18 2022

Answers related to “django rest framework - query limit on nested serializer?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.