From 311c01242be6dab6b74018c5fd96ec93d16a2e02 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Thu, 11 Jan 2024 22:38:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=86=E9=A1=B5=E5=90=8E=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/api/mixin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/common/api/mixin.py b/apps/common/api/mixin.py index 50bb1efbe..e8266d928 100644 --- a/apps/common/api/mixin.py +++ b/apps/common/api/mixin.py @@ -104,9 +104,11 @@ class QuerySetMixin: page = super().paginate_queryset(queryset) serializer_class = self.get_serializer_class() if page and serializer_class and hasattr(serializer_class, 'setup_eager_loading'): - ids = [i.id for i in page] + ids = [str(obj.id) for obj in page] page = self.get_queryset().filter(id__in=ids) page = serializer_class.setup_eager_loading(page) + page_mapper = {str(obj.id): obj for obj in page} + page = [page_mapper.get(_id) for _id in ids if _id in page_mapper] return page