[Django] #36880: using hash index as exclusion constraint on USERNAME_FIELD triggers SystemCheckError

3 views
Skip to first unread message

Django

unread,
Jan 23, 2026, 10:40:11 AM (23 hours ago) Jan 23
to django-...@googlegroups.com
#36880: using hash index as exclusion constraint on USERNAME_FIELD triggers
SystemCheckError
-------------------------------------+-------------------------------------
Reporter: Tilman Koschnick | Type: Bug
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Hi,

with Postgres, a hash index can be used as an exclusion constraint,
functioning the same way a unique btree based constrained. Support for
this has recently been merged to Django:
[https://code.djangoproject.com/ticket/36827]

Using this on a USERNAME_FIELD can be good for index size and performance.
Currently, the auth system checks doesn't detect a hash exclusion
constraint as a viable option though:

{{{
account.User: (auth.E003) 'User.email' must be unique because it is named
as the 'USERNAME_FIELD'.
}}}

The attached patch enhances the check to consider hash constraints as
well.

Cheers, Til
--
Ticket URL: <https://code.djangoproject.com/ticket/36880>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 23, 2026, 10:40:21 AM (23 hours ago) Jan 23
to django-...@googlegroups.com
#36880: using hash index as exclusion constraint on USERNAME_FIELD triggers
SystemCheckError
-------------------------------------+-------------------------------------
Reporter: Tilman Koschnick | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tilman Koschnick):

* Attachment "checks.diff" added.
Reply all
Reply to author
Forward
0 new messages