1๐
โ
You can solve this by filtering your Products
in get_queryset
and use IsDeletedFilteredListSerializer
to only filter your galleries
.
You can do like:
class ProductView(viewsets.ModelViewSet):
serializer_class = ProductSerializer
http_method_names = ['get', 'post', 'head','patch']
paginate_by = 20
def get_queryset(self):
return Product.objects.filter(is_deleted=False)
and in your ProductSerializer
remove the list_serializer_class
option in serializer Meta class.
class ProductSerializer(serializers.ModelSerializer):
galleries = GallerySerializer(many=True, read_only=True)
class Meta:
model = Product
This way you can filter both products
and gallaries
๐คAnush Devendra
Source:stackexchange.com