[Django] #30640: createsuperuser faces error when there is a custom user model with required field with the name same as command default options

10 views
Skip to first unread message

Django

unread,
Jul 15, 2019, 10:54:36 AM7/15/19
to django-...@googlegroups.com
#30640: createsuperuser faces error when there is a custom user model with required
field with the name same as command default options
------------------------------------------+------------------------
Reporter: Hasan Ramezani | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
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`.

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

Django

unread,
Jul 15, 2019, 10:54:57 AM7/15/19
to django-...@googlegroups.com
#30640: createsuperuser faces error when there is a custom user model with required
field with the name same as command default options
--------------------------------+------------------------------------------
Reporter: Hasan Ramezani | Owner: Hasan Ramezani
Type: Bug | Status: assigned
Component: contrib.auth | Version: 2.2
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 Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned


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

Django

unread,
Jul 15, 2019, 12:13:24 PM7/15/19
to django-...@googlegroups.com
#30640: createsuperuser crashes when a custom user model contains required fields
that overlap with default command options.

--------------------------------+------------------------------------------
Reporter: Hasan Ramezani | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: contrib.auth | Version: master
Severity: Normal | Resolution: wontfix

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 felixxm):

* status: assigned => closed
* version: 2.2 => master
* resolution: => wontfix


Comment:

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_DATABASE` environment variable.

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

Reply all
Reply to author
Forward
0 new messages