Jeremy Stretch 1 anno fa
parent
commit
5f87724072
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      netbox/netbox/models/features.py

+ 1 - 1
netbox/netbox/models/features.py

@@ -289,7 +289,7 @@ class CustomFieldsMixin(models.Model):
 
 
             # Validate uniqueness if enforced
             # Validate uniqueness if enforced
             if custom_fields[field_name].validation_unique and value not in CUSTOMFIELD_EMPTY_VALUES:
             if custom_fields[field_name].validation_unique and value not in CUSTOMFIELD_EMPTY_VALUES:
-                if self._meta.model.objects.filter(**{
+                if self._meta.model.objects.exclude(pk=self.pk).filter(**{
                     f'custom_field_data__{field_name}': value
                     f'custom_field_data__{field_name}': value
                 }).exists():
                 }).exists():
                     raise ValidationError(_("Custom field '{name}' must have a unique value.").format(
                     raise ValidationError(_("Custom field '{name}' must have a unique value.").format(