From 200e409d91dbb3875df4d5b37d300bf0b8c70948 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 3 Sep 2021 14:02:57 +0200 Subject: [PATCH] core: minor query optimization Signed-off-by: Jens Langhammer --- authentik/core/api/applications.py | 2 +- authentik/core/api/groups.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/authentik/core/api/applications.py b/authentik/core/api/applications.py index e9b77db73..e8a92e3a6 100644 --- a/authentik/core/api/applications.py +++ b/authentik/core/api/applications.py @@ -67,7 +67,7 @@ class ApplicationSerializer(ModelSerializer): class ApplicationViewSet(UsedByMixin, ModelViewSet): """Application Viewset""" - queryset = Application.objects.all() + queryset = Application.objects.all().prefetch_related("provider") serializer_class = ApplicationSerializer search_fields = [ "name", diff --git a/authentik/core/api/groups.py b/authentik/core/api/groups.py index 6ca292fcb..0e1d88346 100644 --- a/authentik/core/api/groups.py +++ b/authentik/core/api/groups.py @@ -81,7 +81,7 @@ class GroupFilter(FilterSet): class GroupViewSet(UsedByMixin, ModelViewSet): """Group Viewset""" - queryset = Group.objects.all() + queryset = Group.objects.all().select_related("parent").prefetch_related("users") serializer_class = GroupSerializer search_fields = ["name", "is_superuser"] filterset_class = GroupFilter