From 366351dd23d9cbcdfb0e72d2cc287017fe5b3753 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Wed, 13 Dec 2023 12:49:47 -0600 Subject: [PATCH] Fix views test --- netbox/ipam/forms/model_forms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index 5caea70b7..931dd471c 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -341,8 +341,10 @@ class IPAddressForm(TenancyForm, NetBoxModelForm): self.fields['vminterface'].disabled = True self.fields['fhrpgroup'].disabled = True + # Correctly assigned assigned_object if the error exists when validating this form. def add_error(self, field, errors): - if errors.error_dict.get('assigned_object', None): + if isinstance(errors, ValidationError) and hasattr(errors, 'error_dict') and \ + errors.error_dict.get('assigned_object', None): error = errors.error_dict.pop('assigned_object') if isinstance(self.instance.assigned_object, Interface): errors.error_dict.update({'interface': error})