From 486e8f988ca7c37628652410744111d96cd3e79d Mon Sep 17 00:00:00 2001 From: mingi Date: Mon, 26 May 2025 19:11:39 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=B6=80=EC=8A=A4=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EC=88=9C=EC=84=9C=EB=8C=80=EB=A1=9C=20=EB=82=B4?= =?UTF-8?q?=EB=B3=B4=EB=82=B4=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- booth/serializers.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/booth/serializers.py b/booth/serializers.py index 70b50e7..ac17d1c 100644 --- a/booth/serializers.py +++ b/booth/serializers.py @@ -89,13 +89,19 @@ def get_waiting_status(self, obj): class BoothDetailSerializer(serializers.ModelSerializer): booth_menu_info = BoothMenuSerializer(many=True, source='booth_menus') - booth_image_info = BoothImageSerializer(source='booth_images', many=True) + booth_image_info = serializers.SerializerMethodField() total_waiting_teams = serializers.SerializerMethodField() # 전체 대기 팀 class Meta: model = Booth fields = ['booth_id', 'booth_name', 'booth_description', 'booth_location', 'booth_latitude', 'booth_longitude', 'booth_notice', 'operating_status', 'booth_start_time', 'total_waiting_teams', 'booth_menu_info', 'booth_image_info'] + def get_booth_image_info(self, obj): + # Return images ordered by booth_image_id ascending + images = obj.booth_images.all().order_by('booth_image_id') + serializer = BoothImageSerializer(images, many=True, context=self.context) + return serializer.data + def get_total_waiting_teams(self, obj): return Waiting.objects.filter( booth=obj, @@ -103,12 +109,17 @@ def get_total_waiting_teams(self, obj): ).count() class GDGBoothDetailSerializer(serializers.ModelSerializer): - booth_image_info = BoothImageSerializer(source='booth_images', many=True) + booth_image_info = serializers.SerializerMethodField() class Meta: model = Booth fields = ['booth_id', 'booth_name', 'booth_description', 'booth_location', 'booth_notice', 'booth_start_time', 'booth_image_info', 'GDG_id'] + def get_booth_image_info(self, obj): + images = obj.booth_images.all().order_by('booth_image_id') + serializer = BoothImageSerializer(images, many=True, context=self.context) + return serializer.data + class BoothWaitingDetailSerializer(serializers.ModelSerializer): waiting_id = serializers.SerializerMethodField() waiting_status = serializers.SerializerMethodField() # 현재 대기 상태