Skip to content

Commit 65ed047

Browse files
committed
Fixes #6124: Location parent filter should return all child locations (not just those directly assigned)
1 parent b0573f8 commit 65ed047

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

docs/release-notes/version-2.11.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* [#6107](https://github.com/netbox-community/netbox/issues/6107) - Fix rack selection field on device form
1919
* [#6110](https://github.com/netbox-community/netbox/issues/6110) - Fix handling of TemplateColumn values for table export
2020
* [#6123](https://github.com/netbox-community/netbox/issues/6123) - Prevent device from being assigned to mismatched site and location
21+
* [#6124](https://github.com/netbox-community/netbox/issues/6124) - Location `parent` filter should return all child locations (not just those directly assigned)
2122
* [#6130](https://github.com/netbox-community/netbox/issues/6130) - Improve display of assigned models in custom fields list
2223

2324
---

netbox/dcim/filters.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,18 @@ class LocationFilterSet(BaseFilterSet, NameSlugSearchFilterSet):
191191
to_field_name='slug',
192192
label='Site (slug)',
193193
)
194-
parent_id = django_filters.ModelMultipleChoiceFilter(
194+
parent_id = TreeNodeMultipleChoiceFilter(
195195
queryset=Location.objects.all(),
196-
label='Rack group (ID)',
196+
field_name='parent',
197+
lookup_expr='in',
198+
label='Location (ID)',
197199
)
198-
parent = django_filters.ModelMultipleChoiceFilter(
199-
field_name='parent__slug',
200+
parent = TreeNodeMultipleChoiceFilter(
200201
queryset=Location.objects.all(),
202+
field_name='parent',
203+
lookup_expr='in',
201204
to_field_name='slug',
202-
label='Rack group (slug)',
205+
label='Location (slug)',
203206
)
204207

205208
class Meta:

0 commit comments

Comments
 (0)