'Unique field case insensitive constraint
I am trying to ensure that all tags are unique when converted to lowercase. However, when I run the migrate on the following model I receive the following error:
api.Tag: (models.E012) 'constraints' refers to the nonexistent field 'Lower(F(name))'.
class Tag(models.Model):
name = models.CharField(max_length=30)
class Meta:
constraints = [
models.UniqueConstraint(
fields=[Lower('name')],
name='unique_name'
),
]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
