diff --git a/apps/core/serializers/article.py b/apps/core/serializers/article.py index b5bb0cdc..5850ffdf 100644 --- a/apps/core/serializers/article.py +++ b/apps/core/serializers/article.py @@ -2,6 +2,7 @@ from django.utils.translation import gettext from rest_framework import exceptions, serializers +from rest_framework.utils.serializer_helpers import ReturnDict from apps.core.documents import ArticleDocument from apps.core.models import Article, ArticleHiddenReason, Block, Board, Comment, Scrap @@ -11,6 +12,7 @@ HiddenSerializerFieldMixin, HiddenSerializerMixin, ) +from apps.core.serializers.attachment import AttachmentSerializer from apps.core.serializers.topic import TopicSerializer from apps.user.serializers.user import PublicUserSerializer from ara.classes.serializers import MetaDataModelSerializer @@ -315,9 +317,11 @@ def get_side_articles_of_recent_article(self, obj, request): after = None if len(after) == 0 else after[0] return after, before - def get_attachments(self, obj) -> list | None: + def get_attachments(self, obj: Article) -> ReturnDict | None: if self.visible_verdict(obj): - return obj.attachments.all().values_list("id") + attachments = obj.attachments.all() + serializer = AttachmentSerializer(attachments, many=True) + return serializer.data return None def get_my_comment_profile(self, obj):