Skip to content

Commit abe3edb

Browse files
authored
Raise ValidationError if trying to set unique=True on multiobject field (#344)
1 parent 2286ab6 commit abe3edb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

netbox_custom_objects/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,10 +1039,10 @@ def clean(self):
10391039
}
10401040
)
10411041

1042-
# Uniqueness can not be enforced for boolean fields
1043-
if self.unique and self.type == CustomFieldTypeChoices.TYPE_BOOLEAN:
1042+
# Uniqueness can not be enforced for boolean or multiobject fields
1043+
if self.unique and self.type in [CustomFieldTypeChoices.TYPE_BOOLEAN, CustomFieldTypeChoices.TYPE_MULTIOBJECT]:
10441044
raise ValidationError(
1045-
{"unique": _("Uniqueness cannot be enforced for boolean fields")}
1045+
{"unique": _("Uniqueness cannot be enforced for boolean or multiobject fields")}
10461046
)
10471047

10481048
# Check if uniqueness constraint can be applied when changing from non-unique to unique

0 commit comments

Comments
 (0)