From dfe884484d880e9d244950a5cb4b4afc7adb3773 Mon Sep 17 00:00:00 2001 From: imperosol Date: Wed, 1 Apr 2026 14:04:10 +0200 Subject: [PATCH] apply correct default club_status when GET data is missing --- club/forms.py | 9 +++++++-- club/views.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) 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