Opened 8 years ago

Closed 8 years ago

#26412 closed Bug (invalid)

createsupseruser with email login instead of username

Reported by: Adam Owned by: nobody
Component: Core (Management commands) Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have a project that uses email for user authentication and we do not use username at all and I have a custom user model based on AbstractBaseUser.

When running ./ createsupseruser it prompts correctly for just email and password (in response to REQUIRED_FIELDS being set correctly). However, when trying to create the superuser it spits out TypeError: create_superuser() missing 1 required positional argument: 'username' in line 75 of /contrib/auth/management/commands/

The error happens because in contrib/auth/models in the create_superuser and create_user function it's requiring username and email to be passed in but the createsuperuser command is only passing in email because username is not in the REQUIRED_FIELDS.

This seems like a bug in Django to me. Would this be open to a pull request? There are 2 ways I see to fix this, and am very open to recommendation if this is in deed a bug and open to a pull request.

#1 default username and email to None in the manager functions
#2 if email or username are not defined in user_data in, add those to the dict as None before passing to the create_superuser function.

I am seeing this in django 1.9.4 and have also seen it in previous versions of django

Change History (2)

comment:1 Changed 8 years ago by Adam

Type: UncategorizedBug

comment:2 Changed 8 years ago by Claude Paroz

Resolution: invalid
Status: newclosed

If you read carefully the paragraphs above and below, you will see that you are required to provide your own manager class for your custom user model (with create_user/create_superuser methods).

Please reopen if I missed anything.

Note: See TracTickets for help on using tickets.
Back to Top