diff --git a/club/forms.py b/club/forms.py index 56dfd726..3c10dfce 100644 --- a/club/forms.py +++ b/club/forms.py @@ -331,6 +331,11 @@ class ClubSearchForm(forms.ModelForm): initial=True, ) - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) + def __init__(self, *args, data: dict | None = None, **kwargs): + super().__init__(*args, data=data, **kwargs) + if data is not None and "club_status" not in data: + # if the key is missing, it is considered as None, + # even though we want the default True value to be applied in such a case + # so we enforce it. + self.fields["club_status"].value = True self.fields["name"].required = False diff --git a/club/views.py b/club/views.py index 71cf8f0b..6a9963a9 100644 --- a/club/views.py +++ b/club/views.py @@ -210,7 +210,7 @@ class ClubListView(AllowFragment, FormMixin, ListView): def get_form_kwargs(self): res = super().get_form_kwargs() - if self.request.GET: + if self.request.method == "GET": res |= {"data": self.request.GET, "initial": self.request.GET} return res