Code Room
Vibe codingHardvc-g501
Subject Ai code reviewLevel Mid–Senior~17 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

An AI wrote this Django REST Framework serializer + view for a blog feed showing each post's author and tag list. The list endpoint is slow and the query count grows linearly with page size. Find the cause and fix it without changing the JSON shape.

python
class PostSerializer(serializers.ModelSerializer):    author_name = serializers.SerializerMethodField()    tags = serializers.SerializerMethodField()    class Meta:        model = Post        fields = ["id", "title", "author_name", "tags"]    def get_author_name(self, obj):        return obj.author.full_name        # FK    def get_tags(self, obj):        return [t.name for t in obj.tags.all()]  # M2M class PostList(generics.ListAPIView):    queryset = Post.objects.all()    serializer_class = PostSerializer
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.