@@ -28,8 +28,8 @@ class SignalFilterForm(forms.ModelForm):
28
28
search = forms .CharField (min_length = 3 )
29
29
pathogen = forms .ModelChoiceField (queryset = Pathogen .objects .all (), widget = forms .CheckboxSelectMultiple ())
30
30
active = forms .TypedMultipleChoiceField (choices = ActiveChoices .choices , coerce = bool , widget = forms .CheckboxSelectMultiple ())
31
- source = forms .ModelMultipleChoiceField (
32
- queryset = SourceSubdivision . objects . values_list ( 'external_name' , 'external_name' ). distinct () ,
31
+ source = forms .MultipleChoiceField (
32
+ choices = [] ,
33
33
widget = forms .CheckboxSelectMultiple ()
34
34
)
35
35
time_type = forms .ChoiceField (choices = TimeTypeChoices .choices , widget = forms .CheckboxSelectMultiple ())
@@ -78,9 +78,12 @@ def __init__(self, *args, **kwargs) -> None:
78
78
super ().__init__ (* args , ** kwargs )
79
79
80
80
# Set required attribute to False and disable helptext for all fields
81
+ self .fields ["available_geography" ].queryset = self .fields ["available_geography" ].queryset .order_by ("order_id" )
82
+ try :
83
+ self .fields ["source" ].choices = set (SourceSubdivision .objects .values_list ('external_name' , 'external_name' ))
84
+ except SourceSubdivision .DoesNotExist :
85
+ self .fields ["source" ].choices = []
81
86
for field_name , field in self .fields .items ():
82
87
field .required = False
83
88
field .help_text = ''
84
89
field .label = ''
85
- if field_name == "available_geography" :
86
- field .queryset = field .queryset .order_by ("order_id" )
0 commit comments