From b9b24d9399eb6fc63dadde085149c0f847a8b492 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Mon, 18 Dec 2023 09:44:55 -0600 Subject: [PATCH] Modify clean() on model and form to properly catch error --- netbox/ipam/forms/model_forms.py | 2 +- netbox/ipam/models/ip.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index 1febd36d0..5acd6707a 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -375,7 +375,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm): if prev_parent.primary_ip4 == self.instance or prev_parent.primary_ip6 == self.instance: self.add_error( selected_objects[0], - _("Cannot reassign IP address while it is designated as the primary ip for the parent object") + _("Cannot reassign IP address while it is designated as the primary IP for the parent object") ) # Do not allow assigning a network ID or broadcast address to an interface. diff --git a/netbox/ipam/models/ip.py b/netbox/ipam/models/ip.py index d176d3bff..5d3fe4a3a 100644 --- a/netbox/ipam/models/ip.py +++ b/netbox/ipam/models/ip.py @@ -864,11 +864,9 @@ class IPAddress(PrimaryModel): is_primary = True if is_primary and (parent != original_parent): - raise ValidationError({ - 'assigned_object': _( - "Cannot reassign IP address while it is designated as the primary IP for the parent object" - ) - }) + raise ValidationError( + _("Cannot reassign IP address while it is designated as the primary IP for the parent object") + ) # Validate IP status selection if self.status == IPAddressStatusChoices.STATUS_SLAAC and self.family != 6: