[Django] #26412: createsupseruser with email login instead of username

5 views
Skip to first unread message

Django

unread,
Mar 26, 2016, 10:19:56 AM3/26/16
to django-...@googlegroups.com
#26412: createsupseruser with email login instead of username
--------------------------------------------+--------------------
Reporter: awwester | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (Management commands) | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------------+--------------------
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

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

Django

unread,
Mar 26, 2016, 10:20:22 AM3/26/16
to django-...@googlegroups.com
#26412: createsupseruser with email login instead of username
-------------------------------------+-------------------------------------
Reporter: awwester | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.9
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by awwester):

* needs_docs: => 0
* type: Uncategorized => Bug
* needs_tests: => 0
* needs_better_patch: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26412#comment:1>

Django

unread,
Mar 26, 2016, 11:28:09 AM3/26/16
to django-...@googlegroups.com
#26412: createsupseruser with email login instead of username
-------------------------------------+-------------------------------------
Reporter: awwester | Owner: nobody
Type: Bug | Status: closed

Component: Core (Management | Version: 1.9
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* status: new => closed
* resolution: => invalid


Comment:

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_superuser` methods).

Please reopen if I missed anything.

--
Ticket URL: <https://code.djangoproject.com/ticket/26412#comment:2>

Django

unread,
Mar 11, 2024, 8:22:37 AM3/11/24
to django-...@googlegroups.com
#26412: createsupseruser with email login instead of username
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: nobody
Type: Bug | Status: closed
Component: Core (Management | Version: 1.9
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia Bidart):

#35287 was a duplicate of this one.
--
Ticket URL: <https://code.djangoproject.com/ticket/26412#comment:3>
Reply all
Reply to author
Forward
0 new messages