diff --git a/django/contrib/auth/checks.py b/django/contrib/auth/checks.py
index 0de4cf49f1..ab63ea4bef 100644
|
a
|
b
|
from itertools import chain
|
| 2 | 2 | |
| 3 | 3 | from django.apps import apps |
| 4 | 4 | from django.conf import settings |
| | 5 | from django.contrib.postgres.constraints import ExclusionConstraint |
| 5 | 6 | from django.core import checks |
| 6 | 7 | from django.utils.module_loading import import_string |
| 7 | 8 | |
| … |
… |
def check_user_model(app_configs, **kwargs):
|
| 71 | 72 | if not cls._meta.get_field(cls.USERNAME_FIELD).unique and not any( |
| 72 | 73 | constraint.fields == (cls.USERNAME_FIELD,) |
| 73 | 74 | for constraint in cls._meta.total_unique_constraints |
| | 75 | ) and not any( |
| | 76 | isinstance(constraint, ExclusionConstraint) |
| | 77 | and constraint.index_type.lower() == 'hash' |
| | 78 | and constraint.expressions[0][0] == cls.USERNAME_FIELD |
| | 79 | for constraint in cls._meta.constraints |
| 74 | 80 | ): |
| 75 | 81 | if settings.AUTHENTICATION_BACKENDS == [ |
| 76 | 82 | "django.contrib.auth.backends.ModelBackend" |