1 from django
.core
.checks
import register
, Warning
2 from django
.db
import connection
6 SELECT count(*), lower(username)
8 GROUP BY lower(username)
13 def check_case_insensitive_users(app_configs
=None, **kwargs
):
16 cursor
= connection
.cursor()
18 non_unique
= cursor
.fetchall()
20 usernames
= [t
[1] for t
in non_unique
]
22 if len(non_unique
) > 0:
23 txt
= 'There are {0} non-unique usernames: {1}'.format(
25 ', '.join(usernames
[:10] + ['...'])
28 errors
.append(Warning(txt
, id=wid
))