# Is case-insensitive uniquness in PostgeSQL not possible with Django 5.2.7?

**URL:** <https://forum.djangoproject.com/t/is-case-insensitive-uniquness-in-postgesql-not-possible-with-django-5-2-7/43220>\
**Category:** Using the ORM\
**Created:** [October 19, 2025, 7:38pm UTC](https://forum.djangoproject.com/t/is-case-insensitive-uniquness-in-postgesql-not-possible-with-django-5-2-7/43220 "2025-10-19T19:38:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xeon](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/xeon/32/22725_2.png) [@xeon](https://forum.djangoproject.com/u/xeon)\
**Post date:** [October 19, 2025, 7:38pm UTC](https://forum.djangoproject.com/t/is-case-insensitive-uniquness-in-postgesql-not-possible-with-django-5-2-7/43220/1 "2025-10-19T19:38:00Z")

</div>

I noticed I cannot use the Postgres CIEmailField and CICharField anymore so I tried to create a case-insensitive db collation and use that in its place but then I got an error that the case insensitive db collation cannot be used on fields that have unique=True. What I’ve done as a work-around is to remove the unique=True constraint, leave the case insensitive db\_collation attribute, and implement uniqueness at the application level by overriding the save() method. But this doesn’t account bulk\_create() and update() as those do not use the save() method. Am I missing something or is there a better way?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [October 19, 2025, 8:11pm UTC](https://forum.djangoproject.com/t/is-case-insensitive-uniquness-in-postgesql-not-possible-with-django-5-2-7/43220/2 "2025-10-19T20:11:51Z")

</div>

The discussion around this change and some talk about alternative methods can be found at:

> **[Deprecate CICharField, CIEmailField, CITextField](https://groups.google.com/g/django-developers/c/nDMnO98nexY/m/fyY2J-5gAgAJ)**

Superficially, my personal inclination would be to create a generated field as described at [https://groups.google.com/g/django-developers/c/nDMnO98nexY/m/4fhLtlR7AwAJ](https://groups.google.com/g/django-developers/c/nDMnO98nexY/m/4fhLtlR7AwAJ) - but that’s an off-the-cuff reaction to what I’m reading with no real thought behind it.

---

<div class="post-metadata">

**Author:** ![xeon](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/xeon/32/22725_2.png) [@xeon](https://forum.djangoproject.com/u/xeon)\
**Post date:** [October 20, 2025, 7:55pm UTC](https://forum.djangoproject.com/t/is-case-insensitive-uniquness-in-postgesql-not-possible-with-django-5-2-7/43220/3 "2025-10-20T19:55:43Z")

</div>

I ended up taking your advice and creating a second field (generated) that compares the referenced field in lower case to existing values so it has the same result as case-insensitive uniqueness in the end.

`email = models.EmailField(max_length=128, unique=True)`  
`email_lower = models.GeneratedField(`  
`expression=Lower(“email”),`  
`output_field=models.EmailField(),`  
`db_persist=True,`  
`unique=True,`  
`)`
