Django REST — How to show every 5th item from the filtered queryset?

Good day. I have now derived all the filtered data from the database. And need to display only every 5th item. How to do it? Thank you. My code

class CoinCostsSerializer(serializers.ModelSerializer):
 class Meta:
 fields = ('price', 'timestamp')
 model = CoinCosts

 class CoinSerializer(serializers.ModelSerializer):
 class Meta:
 fields = ('symbol', 'crr', 'costs')
 model = Coins
 costs = CoinCostsSerializer(source='filtered_coincosts', many=True)

class DateTimeGteFilter(filters.IsoDateTimeFilter):
 def filter(self, qs, value):
 if value != None:
 return qs.prefetch_related(Prefetch('coincosts_set', to_attr='filtered_coincosts', queryset=CoinCosts.objects.filter(timestamp__gte=value)
 return qs

 class CoinCostFilterSet(filters.FilterSet):
 timestamp = DateTimeGteFilter()

 class Meta:
 model = Coins
 fields = {
 'symbol': ['exact'],

tried to frame [::5] in different places, everywhere error. Don't know where to put and how really to do it
April 19th 20 at 12:23
1 answer
April 19th 20 at 12:25
Jangi at hand, so my answer is -- not a complete solution, and the direction where to dig.

in the method get_queryset:

queryset = queryset.annotate(
 row_number=RawSQL('row_number() OVER (ORDER BY polistirole)', [])
).annotate(rowmod5=F('row_number') % 5).filter(rowmod5=0)


Find more questions by tags Django Rest Framework