﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33613	createsuperuser does not validate usernames that use a UniqueConstraint.	Lucidiot	Lucidiot	"With a custom User model that uses a `UniqueConstraint` instead of `unique=True`, the `manage.py createsuperuser` command does not validate usernames at all.

{{{
#!python
class CustomUser(AbstractBaseUser):
    custom_username = models.CharField(max_length=255)
    USERNAME_FIELD = 'custom_username'

    class Meta:
        constraints = [
            models.UniqueConstraint(fields=['custom_username'], name='unique_usernames'),
        ]
}}}

Running `manage.py createsuperuser` to create a user with a username that already exists then results in an IntegrityError:

{{{
IntegrityError: duplicate key value violates unique constraint ""unique_usernames""
DETAIL:  Key (custom_username)=(foo) already exists.
}}}"	Bug	closed	contrib.auth	4.0	Normal	fixed			Ready for checkin	1	0	0	0	0	0
