[Answered ]-Unique field case insensitive constraint

1👍

Since , you can work with expressions in a UniqueConstraint [Django-doc], so:

class Tag(models.Model):
    name = models.CharField(max_length=30)
    
    class Meta:
        constraints = [
            models.UniqueConstraint(
                Lower('name'),
                name='unique_name'
            )
        ]

Leave a comment