|
|
@@ -159,6 +159,14 @@ class LocationImportForm(NetBoxModelImportForm):
|
|
|
model = Location
|
|
|
fields = ('site', 'parent', 'name', 'slug', 'status', 'tenant', 'description', 'tags')
|
|
|
|
|
|
+ def __init__(self, data=None, *args, **kwargs):
|
|
|
+ super().__init__(data, *args, **kwargs)
|
|
|
+
|
|
|
+ if data:
|
|
|
+ # Limit location queryset by assigned site
|
|
|
+ params = {f"site__{self.fields['site'].to_field_name}": data.get('site')}
|
|
|
+ self.fields['parent'].queryset = self.fields['parent'].queryset.filter(**params)
|
|
|
+
|
|
|
|
|
|
class RackRoleImportForm(NetBoxModelImportForm):
|
|
|
slug = SlugField()
|