From 65ed04708418f0edca7b88a0d2d4507c9addc990 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Sun, 11 Apr 2021 13:42:24 -0400 Subject: [PATCH] Fixes #6124: Location parent filter should return all child locations (not just those directly assigned) --- docs/release-notes/version-2.11.md | 1 + netbox/dcim/filters.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/release-notes/version-2.11.md b/docs/release-notes/version-2.11.md index cd75d141b..0fbbb2f9c 100644 --- a/docs/release-notes/version-2.11.md +++ b/docs/release-notes/version-2.11.md @@ -18,6 +18,7 @@ * [#6107](https://github.com/netbox-community/netbox/issues/6107) - Fix rack selection field on device form * [#6110](https://github.com/netbox-community/netbox/issues/6110) - Fix handling of TemplateColumn values for table export * [#6123](https://github.com/netbox-community/netbox/issues/6123) - Prevent device from being assigned to mismatched site and location +* [#6124](https://github.com/netbox-community/netbox/issues/6124) - Location `parent` filter should return all child locations (not just those directly assigned) * [#6130](https://github.com/netbox-community/netbox/issues/6130) - Improve display of assigned models in custom fields list --- diff --git a/netbox/dcim/filters.py b/netbox/dcim/filters.py index d8586eb33..1a7ac266f 100644 --- a/netbox/dcim/filters.py +++ b/netbox/dcim/filters.py @@ -191,15 +191,18 @@ class LocationFilterSet(BaseFilterSet, NameSlugSearchFilterSet): to_field_name='slug', label='Site (slug)', ) - parent_id = django_filters.ModelMultipleChoiceFilter( + parent_id = TreeNodeMultipleChoiceFilter( queryset=Location.objects.all(), - label='Rack group (ID)', + field_name='parent', + lookup_expr='in', + label='Location (ID)', ) - parent = django_filters.ModelMultipleChoiceFilter( - field_name='parent__slug', + parent = TreeNodeMultipleChoiceFilter( queryset=Location.objects.all(), + field_name='parent', + lookup_expr='in', to_field_name='slug', - label='Rack group (slug)', + label='Location (slug)', ) class Meta: