#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 |
Description
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 ./manage.py 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/createsuperuser.py.
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 createsuperuser.py, 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 (3)
comment:1 by , 10 years ago
| Type: | Uncategorized → Bug |
|---|
comment:2 by , 10 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
If you read carefully the paragraphs above and below https://docs.djangoproject.com/en/stable/topics/auth/customizing/#django.contrib.auth.models.CustomUserManager, you will see that you are required to provide your own manager class for your custom user model (with
create_user/create_superusermethods).Please reopen if I missed anything.