From 37b59bb5b9e0641a0de823aae1cd9bbe139aa51e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 1 Mar 2021 18:30:27 +0100 Subject: [PATCH] lib: sort GroupedModelChoiceField by name closes #602 --- authentik/lib/widgets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authentik/lib/widgets.py b/authentik/lib/widgets.py index f2104313b..2fb833941 100644 --- a/authentik/lib/widgets.py +++ b/authentik/lib/widgets.py @@ -10,7 +10,7 @@ class GroupedModelChoiceIterator(ModelChoiceIterator): def __iter__(self): if self.field.empty_label is not None: yield ("", self.field.empty_label) - queryset = self.queryset + queryset = self.queryset.order_by("name") # Can't use iterator() when queryset uses prefetch_related() if not queryset._prefetch_related_lookups: queryset = queryset.iterator()