I'm retreiving Category
and its outfits
list. My problem is there are too many outfits
belong to a category
.
class CategoryListAPIView(generics.RetrieveAPIView):
serializer_class = CategoryDetailSerializer
...
class CategoryDetailSerializer(serializers.ModelSerializer):
outfits = serializers.SerializerMethodField()
...
class Meta:
model = Category
fields = (
...
'outfits',
...
)
def get_outfits(self, obj): //This is returning 39 items.
// Can we paginate this?
if obj.outfits is not None:
return OutfitListSerializer(obj.outfits, many=True).data
return None
Can we paginate it so that user can first see 24 outfits
and refresh to see the rest of outfits
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…