Skip to content

Commit 43279fd

Browse files
committed
Fixes #13293: Limit interface selector for IP address to current device/VM
1 parent 69545fd commit 43279fd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

netbox/ipam/forms/model_forms.py

+9
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,15 @@ def __init__(self, *args, **kwargs):
355355
):
356356
self.initial['primary_for_parent'] = True
357357

358+
if type(instance.assigned_object) is Interface:
359+
self.fields['interface'].widget.add_query_params({
360+
'device_id': instance.assigned_object.device.pk,
361+
})
362+
elif type(instance.assigned_object) is VMInterface:
363+
self.fields['vminterface'].widget.add_query_params({
364+
'virtual_machine_id': instance.assigned_object.virtual_machine.pk,
365+
})
366+
358367
# Disable object assignment fields if the IP address is designated as primary
359368
if self.initial.get('primary_for_parent'):
360369
self.fields['interface'].disabled = True

0 commit comments

Comments
 (0)