From e3c85929aac847025b654f196db4304f398d99c4 Mon Sep 17 00:00:00 2001 From: Tobias Macey Date: Wed, 5 Nov 2025 16:31:18 -0500 Subject: [PATCH] fix: Add author field to ContentSerializer for Forums V2 API compatibility The Forums V2 API responses were missing the 'author' attribute that is expected by the frontend, causing issues when displaying comment/thread author information. Analysis showed that: - The ContentSerializer already has 'username' field mapped to 'author_username' - Frontend expects an 'author' field in addition to 'username' - Both should reference the same source data (author_username) This change adds the 'author' field to the DRF serializer, mapped to the same 'author_username' source as 'username', maintaining backward compatibility while fixing the missing field issue. Fixes compatibility issues with Forums V2 API responses. --- forum/serializers/contents.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/forum/serializers/contents.py b/forum/serializers/contents.py index d01f69eb..a8c5c319 100644 --- a/forum/serializers/contents.py +++ b/forum/serializers/contents.py @@ -67,6 +67,9 @@ class ContentSerializer(serializers.Serializer[dict[str, Any]]): at_position_list = serializers.ListField(default=[]) user_id = serializers.CharField(source="author_id") username = serializers.CharField(source="author_username", allow_null=True) + author = serializers.CharField( + source="author_username", allow_null=True, required=False + ) commentable_id = serializers.CharField(default="course") votes = VoteSummarySerializer() abuse_flaggers = serializers.ListField(child=serializers.CharField(), default=[])