In Django Rest Framework, how to limit number foreign key objects being serialized
<p>I'm serialzing a Product model and its comments. Here's my simple code:</p>

<pre><code>class ProductSerializer(serializers.HyperlinkedModelSerializer):
    comment_set = CommentSerializer(many=True, read_only=True)
    class Meta:
        model = Product
        fields = [
            'title',
            'comment_set'
        ]


class CommentSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Comment
        fields = [
            'text',
        ]


class Comment(models.Model):
    product = models.ForeignKey(Product, null=True, blank=True, db_index=True)


class Product(models.Model):
    title = models.CharField(max_length=50)
    ...
</code></pre>

<p>Problem:
If the product has many comments. For example, 500 comments. All 500 of them got serialized.</p>

<p>How to limit the result to a number of my own choosing, like 100 comments?</p>

<p>I've done some research before posting this but only found questions about filtering.</p>

<p>Thank you.</p>