From fd88b5c64190136e27ad56bf154fd93033af2ccf Mon Sep 17 00:00:00 2001 From: Ilona Podliashanyk Date: Fri, 8 Nov 2024 16:26:53 +0100 Subject: [PATCH] Define form attrs inside dunder init This make filter fields render correctly --- python/nav/web/seeddb/forms/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/python/nav/web/seeddb/forms/__init__.py b/python/nav/web/seeddb/forms/__init__.py index 54befbe69c..a73db4a143 100644 --- a/python/nav/web/seeddb/forms/__init__.py +++ b/python/nav/web/seeddb/forms/__init__.py @@ -169,7 +169,12 @@ class RoomFilterForm(forms.Form): Location.objects.order_by('id').all(), required=False ) location.widget.attrs.update({"class": "select"}) - attrs = get_single_layout(heading="Filter rooms", row=[location]) + + def __init__(self, *args, **kwargs): + super(RoomFilterForm, self).__init__(*args, **kwargs) + self.attrs = get_single_layout( + heading="Filter rooms", filter_fields=[self["location"]] + ) class RoomForm(forms.ModelForm): @@ -285,7 +290,12 @@ class NetboxTypeFilterForm(forms.Form): """Form for filtering a netbox type by vendor""" vendor = forms.ModelChoiceField(Vendor.objects.order_by('id').all(), required=False) - attrs = get_single_layout(heading="Filter types", row=[vendor]) + + def __init__(self, *args, **kwargs): + super(NetboxTypeFilterForm, self).__init__(*args, **kwargs) + self.attrs = get_single_layout( + heading="Filter types", filter_fields=[self["vendor"]] + ) class NetboxTypeForm(forms.ModelForm):