#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)
Change History (4)
by , 3 years ago
Attachment: | createsuperuser-username_field.patch added |
---|
comment:1 by , 3 years ago
Cc: | added |
---|
comment:2 by , 3 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Summary: | createsuperuser bug → createsuperuser 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 , 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.
patch to add the username positional parameter