Django Rest Framework AttributeError: 'list' object has no attribute 'filter'

День добрый!

Проблемы с сериализацией, не применяется лист фильтр, хотя делаю всё по примеру.

class FilterSerializerProductCategory(serializers.ListSerializer):

    def to_representation(self, data):
        data = data.filter(parent=None)
        return super().to_representation(data)


class RecursiveSerializerProductCategory(serializers.Serializer):

    def to_representation(self, value):
        serializer = self.parent.parent.__class__(value, context=self.context)
        return serializer.data

class ProductCategorySerializer(serializers.ModelSerializer):

    children = RecursiveSerializerProductCategory(many=True)

    class Meta:
        list_serializer_class = FilterSerializerProductCategory
        model = ProductCategory
        fields = ('id', 'name', 'code', 'parent', 'children')

Выдаёт ошибку: AttributeError: 'list' object has no attribute 'filter'

view.py:

class ProductCategoryList(generics.ListAPIView):
    
    queryset = ProductCategory.objects.all()
    serializer_class = ProductCategorySerializer

model.py:

class ProductCategory(MPTTModel):
    """категории продуктов"""

    name = models.CharField(max_length=255)
    code = models.CharField(max_length=255, null=True, blank=True,)
    parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children', db_index=True)

Ответы (1 шт):

Автор решения: Artur

Добавьте в вюшку pagination_class = None

class ProductCategoryList(generics.ListAPIView):
    
    queryset = ProductCategory.objects.all()
    serializer_class = ProductCategorySerializer
    pagination_class = None
→ Ссылка