From 641e75a90518ff7fdc71662601bac67540baa56a Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Tue, 16 Jan 2024 16:43:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E7=BB=84=E5=88=97?= =?UTF-8?q?=E8=A1=A8=20=E7=94=A8=E6=88=B7=E6=95=B0=E9=87=8F=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/serializers/group.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/users/serializers/group.py b/apps/users/serializers/group.py index b87ba4a0e..4c0de20f6 100644 --- a/apps/users/serializers/group.py +++ b/apps/users/serializers/group.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -from django.db.models import Count +from django.db.models import Count, Q from django.utils.translation import gettext_lazy as _ from rest_framework import serializers @@ -46,7 +46,7 @@ class UserGroupSerializer(ResourceLabelsMixin, BulkOrgResourceModelSerializer): def setup_eager_loading(cls, queryset): """ Perform necessary eager loading of data. """ queryset = queryset.prefetch_related('labels', 'labels__label') \ - .annotate(users_amount=Count('users')) + .annotate(users_amount=Count('users', filter=Q(users__is_service_account=False))) return queryset