Skip to content

Commit b38bb64

Browse files
committed
Fixes #3831: Fix API-driven filter field rendering (#3812 regression)
1 parent c2dc243 commit b38bb64

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

docs/release-notes/version-2.6.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# v2.6.11 (FUTURE)
2+
3+
## Bug Fixes
4+
5+
* [#3831](https://github.com/netbox-community/netbox/issues/3831) - Fix API-driven filter field rendering (#3812 regression)
6+
7+
---
8+
19
# v2.6.10 (2020-01-02)
210

311
## Enhancements

netbox/circuits/forms.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ class CircuitFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm
302302
widget=APISelectMultiple(
303303
api_url="/api/dcim/regions/",
304304
value_field="slug",
305+
filter_for={
306+
'site': 'region'
307+
}
305308
)
306309
)
307310
site = FilterChoiceField(

netbox/dcim/forms.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,16 +651,15 @@ class RackFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm):
651651
}
652652
)
653653
)
654-
group_id = ChainedModelChoiceField(
655-
label='Rack group',
656-
queryset=RackGroup.objects.prefetch_related('site'),
657-
chains=(
658-
('site', 'site'),
654+
group_id = FilterChoiceField(
655+
queryset=RackGroup.objects.prefetch_related(
656+
'site'
659657
),
660-
required=False,
658+
label='Rack group',
659+
null_label='-- None --',
661660
widget=APISelectMultiple(
662661
api_url="/api/dcim/rack-groups/",
663-
null_option=True,
662+
null_option=True
664663
)
665664
)
666665
status = forms.MultipleChoiceField(
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
<select name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% for group_name, group_choices, group_index in widget.optgroups %}{% if group_name %}
2-
<optgroup label="{{ group_name }}">{% endif %}{% for widget in group_choices %}{% if widget.attrs.selected %}
3-
{% include widget.template_name %}{% endif %}{% endfor %}{% if group_name %}
4-
</optgroup>{% endif %}{% endfor %}
1+
<select name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>
2+
{% for group_name, group_choices, group_index in widget.optgroups %}
3+
{% if group_name %}<optgroup label="{{ group_name }}">{% endif %}
4+
{% for option in group_choices %}
5+
{% if option.attrs.selected or option.value == "null" %}{% include option.template_name with widget=option %}{% endif %}
6+
{% endfor %}
7+
{% if group_name %}</optgroup>{% endif %}
8+
{% endfor %}
59
</select>

netbox/virtualization/forms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ class VirtualMachineFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFil
563563
widget=APISelectMultiple(
564564
api_url='/api/dcim/regions/',
565565
value_field="slug",
566-
null_option=True,
566+
filter_for={
567+
'site': 'region'
568+
}
567569
)
568570
)
569571
site = FilterChoiceField(

0 commit comments

Comments
 (0)