lib: don't order_by on widget because PolicyBindingModel, order in form

This commit is contained in:
Jens Langhammer 2021-03-01 19:23:09 +01:00
parent 88ce93ab04
commit 644a03e40e
4 changed files with 6 additions and 4 deletions

View file

@ -12,7 +12,7 @@ class ApplicationForm(forms.ModelForm):
def __init__(self, *args, **kwargs): # pragma: no cover
super().__init__(*args, **kwargs)
self.fields["provider"].queryset = (
Provider.objects.all().order_by("pk").select_subclasses()
Provider.objects.all().order_by("name").select_subclasses()
)
class Meta:

View file

@ -34,7 +34,8 @@ class FlowStageBindingForm(forms.ModelForm):
"""FlowStageBinding Form"""
stage = GroupedModelChoiceField(
queryset=Stage.objects.all().select_subclasses(), to_field_name="stage_uuid"
queryset=Stage.objects.all().order_by("name").select_subclasses(),
to_field_name="stage_uuid",
)
def __init__(self, *args, **kwargs):

View file

@ -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.order_by("name")
queryset = self.queryset
# Can't use iterator() when queryset uses prefetch_related()
if not queryset._prefetch_related_lookups:
queryset = queryset.iterator()

View file

@ -15,7 +15,8 @@ class PolicyBindingForm(forms.ModelForm):
to_field_name="pbm_uuid",
)
policy = GroupedModelChoiceField(
queryset=Policy.objects.all().select_subclasses(), required=False
queryset=Policy.objects.all().order_by("name").select_subclasses(),
required=False,
)
group = forms.ModelChoiceField(
queryset=Group.objects.all().order_by("name"), required=False