Fix test to check for PK

This commit is contained in:
Daniel Sheppard 2023-12-21 14:39:56 -06:00
parent 9374890724
commit ec58b5338f

View File

@ -369,6 +369,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
'primary_for_parent', _("Only IP addresses assigned to an interface can be designated as primary IPs.") 'primary_for_parent', _("Only IP addresses assigned to an interface can be designated as primary IPs.")
) )
if self.instance.pk:
prev_interface = self.instance.interface.first() or self.instance.vminterface.first() prev_interface = self.instance.interface.first() or self.instance.vminterface.first()
# If the prev interface exists and does not match the new interface, we need to validate it isn't set as primary # If the prev interface exists and does not match the new interface, we need to validate it isn't set as primary
# for the parent # for the parent