Opened 6 years ago
Closed 6 years ago
#30640 closed Bug (wontfix)
createsuperuser crashes when a custom user model contains required fields that overlap with default command options.
| Reported by: | Hasan Ramezani | Owned by: | Hasan Ramezani |
|---|---|---|---|
| Component: | contrib.auth | Version: | dev |
| 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
If we have a User model like this:
class User(AbstractUser):
database = models.CharField(max_length=20)
REQUIRED_FIELDS = ['database']
When we run python manage.py createsuperuser, we will get this error:
argparse.ArgumentError: argument --database: conflicting option string: --database.
Because of createsuperuser adds a --database option by default and also database is a required field of User model and command tries to add --database again.
Possible solution: add a prefix to fields which already added by createsupperuser.
Change History (2)
comment:1 by , 6 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:2 by , 6 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | assigned → closed |
| Summary: | createsuperuser faces error when there is a custom user model with required field with the name same as command default options → createsuperuser crashes when a custom user model contains required fields that overlap with default command options. |
| Version: | 2.2 → master |
Note:
See TracTickets
for help on using tickets.
Thanks for the report, however even with a prefix we can encounter conflicts. I don't think that we should change this, user can always use
DJANGO_SUPERUSER_DATABASEenvironment variable.