Просмотр исходного кода

Fixes #4756: Filter parent group by site when creating rack groups

Jeremy Stretch 5 лет назад
Родитель
Сommit
2e5058c4c9
2 измененных файлов с 9 добавлено и 1 удалено
  1. 1 0
      docs/release-notes/version-2.8.md
  2. 8 1
      netbox/dcim/forms.py

+ 1 - 0
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
 
 ---
 

+ 8 - 1
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(),