When UniqueConstraint
of a model is violated, an exception is raised. How can I make it to behave the same as violation of a field with unique=True
?
identifier = models.CharField("id", max_length=30, unique=True, blank=True, null=True, validators=[validate_id])
class Meta:
constraints = [
models.UniqueConstraint(
Lower("identifier"),
name="id_case_insensitive_constraint"
)
]
Here I want a form's form_invalid
called with the same field errors and all that, whether the input is exactly the same as another one or its only difference is case distinction.