Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#33122 closed Bug (invalid)

createsuperuser fails when using USERNAME_FIELD

Reported by: Raymond Olavides Owned by: nobody
Component: contrib.auth Version: 3.2
Severity: Normal Keywords: createsuperuser, command-line utility
Cc: Raymond Olavides Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Creation of user via Django’s command-line utility fails when using USERNAME_FIELD.

Positional parameter is missing.

Attachments (1)

createsuperuser-username_field.patch (841 bytes ) - added by Raymond Olavides 3 years ago.
patch to add the username positional parameter

Download all attachments as: .zip

Change History (4)

by Raymond Olavides, 3 years ago

patch to add the username positional parameter

comment:1 by Raymond Olavides, 3 years ago

Cc: Raymond Olavides added

comment:2 by Tim Graham, 3 years ago

Resolution: invalid
Status: newclosed
Summary: createsuperuser bugcreatesuperuser fails when using USERNAME_FIELD

This appears to be a usage mistake. You need to use a custom manager with your user model that defines create_superuser() with appropriate parameters (corresponding to your USERNAME_FIELD.

For an example of how this works, you can look at Django's test for createsuperuser which uses a custom user that defines REQUIRED_FIELDS.

comment:3 by Raymond Olavides, 3 years ago

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.

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