lib: don't order_by on widget because PolicyBindingModel, order in form
This commit is contained in:
parent
88ce93ab04
commit
644a03e40e
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue