[Django] #33122: createsuperuser bug

11 views
Skip to first unread message

Django

unread,
Sep 20, 2021, 9:01:41 PM9/20/21
to django-...@googlegroups.com
#33122: createsuperuser bug
-------------------------------------+-------------------------------------
Reporter: rolavides | Owner: nobody
Type: Bug | Status: new
Component: | Version: 3.2
contrib.auth | Keywords: createsuperuser,
Severity: Normal | command-line utility
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Creation of user via Django’s command-line utility fails when using
USERNAME_FIELD.

Positional parameter is missing.

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

Django

unread,
Sep 20, 2021, 9:03:18 PM9/20/21
to django-...@googlegroups.com
#33122: createsuperuser bug
-------------------------------------+-------------------------------------
Reporter: rolavides | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 3.2
Severity: Normal | Resolution:
Keywords: createsuperuser, | Triage Stage:
command-line utility | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by rolavides):

* Attachment "createsuperuser-username_field.patch" added.

patch to add the username positional parameter

Django

unread,
Sep 20, 2021, 9:08:58 PM9/20/21
to django-...@googlegroups.com
#33122: createsuperuser bug
-------------------------------------+-------------------------------------
Reporter: Raymond Olavides | Owner: nobody
Type: Bug | Status: new

Component: contrib.auth | Version: 3.2
Severity: Normal | Resolution:
Keywords: createsuperuser, | Triage Stage:
command-line utility | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Raymond Olavides):

* cc: Raymond Olavides (added)


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

Django

unread,
Sep 20, 2021, 10:01:30 PM9/20/21
to django-...@googlegroups.com
#33122: createsuperuser fails when using USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: Raymond Olavides | Owner: nobody
Type: Bug | Status: closed
Component: contrib.auth | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: createsuperuser, | Triage Stage:
command-line utility | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

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


Comment:

This appears to be a usage mistake. You need to use a custom manager with
your user model that defines
[https://docs.djangoproject.com/en/stable/topics/auth/customizing/#django.contrib.auth.models.CustomUserManager.create_superuser
create_superuser()] with appropriate parameters (corresponding to your
`USERNAME_FIELD`.

For an example of how this works, you can look at Django's
[https://github.com/django/django/blob/32b7ffc2bbfd1ae055bdbe287f8598de731adce1/tests/auth_tests/test_management.py#L335
test] for `createsuperuser` which uses
[https://github.com/django/django/blob/32b7ffc2bbfd1ae055bdbe287f8598de731adce1/tests/auth_tests/models/custom_user.py
a custom user] that defines `REQUIRED_FIELDS`.

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

Django

unread,
Sep 21, 2021, 3:06:16 AM9/21/21
to django-...@googlegroups.com
#33122: createsuperuser fails when using USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: Raymond Olavides | Owner: nobody
Type: Bug | Status: closed
Component: contrib.auth | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: createsuperuser, | Triage Stage:
command-line utility | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Raymond Olavides):

The only missing column from the custom UserModel is username, the rest is
the same with the original UserModel.

Thank you for pointing out a usage issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/33122#comment:3>

Reply all
Reply to author
Forward
0 new messages