Paginate relationship in Django REST Framework?
问题 We are using Django REST Framework for our API and we have a need to paginate relationship fields that return multiple items. To demonstrate using examples similar to those in the documentation: class TrackSerializer(serializers.ModelSerializer): class Meta: model = Track fields = ('order', 'title') class AlbumSerializer(serializers.ModelSerializer): tracks = TrackSerializer(many=True) class Meta: model = Album fields = ('album_name', 'artist', 'tracks') Example serialized output for an Album