From 2e5058c4c99298624d3b15c4784f29f0ad50ee0d Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 15 Jun 2020 10:02:35 -0400 Subject: [PATCH] Fixes #4756: Filter parent group by site when creating rack groups --- docs/release-notes/version-2.8.md | 1 + netbox/dcim/forms.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index d9ddb2297..10a4e33f5 100644 --- a/docs/release-notes/version-2.8.md +++ b/docs/release-notes/version-2.8.md @@ -16,6 +16,7 @@ * [#4736](https://github.com/netbox-community/netbox/issues/4736) - Add cable trace endpoints for pass-through ports * [#4737](https://github.com/netbox-community/netbox/issues/4737) - Fix display of role labels in virtual machines table * [#4743](https://github.com/netbox-community/netbox/issues/4743) - Allow users to create "next available" IPs without needing permission to create prefixes +* [#4756](https://github.com/netbox-community/netbox/issues/4756) - Filter parent group by site when creating rack groups --- diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 0df59c475..bdcff7121 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -363,7 +363,14 @@ class SiteFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm): class RackGroupForm(BootstrapMixin, forms.ModelForm): site = DynamicModelChoiceField( - queryset=Site.objects.all() + queryset=Site.objects.all(), + to_field_name='slug', + widget=APISelect( + value_field='slug', + filter_for={ + 'parent': 'site', + } + ) ) parent = DynamicModelChoiceField( queryset=RackGroup.objects.all(),