[Fixed]-Queryset is returned inside children key

1👍

Add another serializer that can serialize your children.

class ReviewSeraializerChild(serializers.ModelSerializer):
    class Meta:
        model = Review


class ReviewSeraializer(serializers.ModelSerializer):
    reply_count = serializers.SerializerMethodField()
    children = ReviewSeraializerChild(many=True)

    class Meta:
        model = Review
        read_only = ('id',)
        fields = ('id', 'content_type', 'object_id', 'parent', 'review', 'children', 'reply_count', 'created')

    def get_reply_count(self, obj):
        if obj.is_parent:
            return obj.children().count()
        return 0

But you must write your custom create() and update() functions for nested fieldsenter image description here.

Leave a comment