#33613: manage.py createsuperuser does not validate usernames that use a
UniqueConstraint
----------------------------------------+------------------------
               Reporter:  Lucidiot      |          Owner:  nobody
                   Type:  Bug           |         Status:  new
              Component:  contrib.auth  |        Version:  4.0
               Severity:  Normal        |       Keywords:
           Triage Stage:  Unreviewed    |      Has patch:  0
    Needs documentation:  0             |    Needs tests:  0
Patch needs improvement:  0             |  Easy pickings:  0
                  UI/UX:  0             |
----------------------------------------+------------------------
 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.
 }}}

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fdf72b6f9-8544fe93-d02b-43cf-8377-b6c05b035956-000000%40eu-central-1.amazonses.com.

Reply via email to