Skip to content

Commit 8571f42

Browse files
abhi1693jeremystretch
authored andcommitted
fixed location import #14064
1 parent 276a73f commit 8571f42

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

netbox/dcim/forms/bulk_import.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ class Meta:
159159
model = Location
160160
fields = ('site', 'parent', 'name', 'slug', 'status', 'tenant', 'description', 'tags')
161161

162+
def __init__(self, data=None, *args, **kwargs):
163+
super().__init__(data, *args, **kwargs)
164+
165+
if data:
166+
# Limit location queryset by assigned site
167+
params = {f"site__{self.fields['site'].to_field_name}": data.get('site')}
168+
self.fields['parent'].queryset = self.fields['parent'].queryset.filter(**params)
169+
162170

163171
class RackRoleImportForm(NetBoxModelImportForm):
164172
slug = SlugField()

0 commit comments

Comments
 (0)