[Django] #27769: Impossible to call createsuperuser from call_command

49 views
Skip to first unread message

Django

unread,
Jan 23, 2017, 11:46:13 PM1/23/17
to django-...@googlegroups.com
#27769: Impossible to call createsuperuser from call_command
-------------------------------------+-------------------------------------
Reporter: Kenny | Owner: nobody
Loveall |
Type: Bug | Status: new
Component: Core | Version: 1.8
(Management commands) |
Severity: Normal | Keywords: createsuperuser
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
From what I can tell, it is impossible to call the createsuperuser command
using the call_command function.

If this is intentional, it should be documented on one of the two
functions.

**Steps to Reproduce:**
run "call_command('createsuperuser', noinput=True, username='test',
email='te...@example.com')" from a non-interactive command (such as calling
it inside a view).

**Expected outcome:**
Superuser is created without a password.

**Observed outcome:**
500 error and message "Superuser creation skipped due to not running in a
TTY. You can run `manage.py createsuperuser` in your project to create one
manually." logged.

From what I can tell as well, there's no way to run createsuperuser and
have it create a user without a password as the documentation states is
possible ("When run non-interactively, no password will be set").

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

Django

unread,
Jan 24, 2017, 3:20:04 AM1/24/17
to django-...@googlegroups.com
#27769: createsuperuser command missing docs about no-input/interactive
---------------------------------+------------------------------------
Reporter: Kenny Loveall | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: createsuperuser | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* component: Core (Management commands) => Documentation
* version: 1.8 => master
* stage: Unreviewed => Accepted


Comment:

The issue stems from the fact that the `--no-input` command line flag is
translating to the `interactive` variable which should be used when
calling the command through `call_command`.
`call_command('createsuperuser', interactive=False, username='test',
email=​'te...@example.com')` should then work.

The documentation should really be improved in this case
(https://docs.djangoproject.com/en/stable/ref/django-
admin/#createsuperuser).

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

Django

unread,
Jan 26, 2017, 3:34:56 AM1/26/17
to django-...@googlegroups.com
#27769: createsuperuser command missing docs about no-input/interactive
---------------------------------+-----------------------------------------
Reporter: Kenny Loveall | Owner: Andrew Nester
Type: Bug | Status: assigned

Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: createsuperuser | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* status: new => assigned
* owner: nobody => Andrew Nester
* has_patch: 0 => 1


Comment:

I've added PR for this [https://github.com/django/django/pull/7949 #PR]

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

Django

unread,
Jan 26, 2017, 8:42:15 AM1/26/17
to django-...@googlegroups.com
#27769: createsuperuser command missing docs about no-input/interactive
---------------------------------+-----------------------------------------
Reporter: Kenny Loveall | Owner: Andrew Nester
Type: Bug | Status: assigned
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: createsuperuser | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


Comment:

I think it's more appropriate to highlight this in the `call_command()`
documentation as it applies to any command that takes the `--no-input`
argument. More generally, we should instruct users how to figure out the
name to pass for any option. I'm not sure if there's a way besides looking
up `dest='...'` in the source code.

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

Django

unread,
Jan 26, 2017, 9:07:19 AM1/26/17
to django-...@googlegroups.com
#27769: createsuperuser command missing docs about no-input/interactive
---------------------------------+-----------------------------------------
Reporter: Kenny Loveall | Owner: Andrew Nester
Type: Bug | Status: assigned
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: createsuperuser | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


Comment:

I've updated my PR according to comments.

--
Ticket URL: <https://code.djangoproject.com/ticket/27769#comment:4>

Django

unread,
Jan 26, 2017, 5:37:23 PM1/26/17
to django-...@googlegroups.com
#27769: createsuperuser command missing docs about no-input/interactive
---------------------------------+-----------------------------------------
Reporter: Kenny Loveall | Owner: Andrew Nester
Type: Bug | Status: assigned
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: createsuperuser | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

Comment (by Kenny Loveall):

Wonderful! That does work. I would think it should be highlighted both
places.

Personally I could never figure out how to make createsuperuser run in a
non-interactive fashion (I assumed the --no-input flag did that). Nowhere
on the documentation page for manage.py commands does it mention the
--interactive=False flag (--no-input, however is mentioned on many of the
commands which is why I assumed it was the way to make this work).

--
Ticket URL: <https://code.djangoproject.com/ticket/27769#comment:5>

Django

unread,
Jan 27, 2017, 10:26:39 AM1/27/17
to django-...@googlegroups.com
#27769: createsuperuser command missing docs about no-input/interactive
---------------------------------+-----------------------------------------
Reporter: Kenny Loveall | Owner: Andrew Nester
Type: Bug | Status: assigned
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: createsuperuser | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

Comment (by Claude Paroz):

The flag names when calling from command line do not always match the
kwarg names that `call_command` must use (depends on the `dest` name in
the command option definitions).

--
Ticket URL: <https://code.djangoproject.com/ticket/27769#comment:6>

Django

unread,
Jan 27, 2017, 3:44:44 PM1/27/17
to django-...@googlegroups.com
#27769: createsuperuser command missing docs about no-input/interactive
-------------------------------------+-------------------------------------

Reporter: Kenny Loveall | Owner: Andrew
| Nester
Type: Bug | Status: assigned
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: createsuperuser | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


Comment:

Besides the documentation enhancement, #27787 will improve the situation
so that `call_command()` rejects unexpected options.

--
Ticket URL: <https://code.djangoproject.com/ticket/27769#comment:7>

Django

unread,
Jan 27, 2017, 4:13:04 PM1/27/17
to django-...@googlegroups.com
#27769: createsuperuser command missing docs about no-input/interactive
-------------------------------------+-------------------------------------
Reporter: Kenny Loveall | Owner: Andrew
| Nester
Type: Bug | Status: closed
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed

Keywords: createsuperuser | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c8d21f335113dcf6009d7aa9810d4e77dc58c75d" c8d21f33]:
{{{
#!CommitTicketReference repository=""
revision="c8d21f335113dcf6009d7aa9810d4e77dc58c75d"
Fixed #27769 -- Documented option naming differences between django-admin
and call_command().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27769#comment:8>

Django

unread,
Jan 27, 2017, 5:22:13 PM1/27/17
to django-...@googlegroups.com
#27769: createsuperuser command missing docs about no-input/interactive
-------------------------------------+-------------------------------------
Reporter: Kenny Loveall | Owner: Andrew
| Nester
Type: Bug | Status: closed
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed
Keywords: createsuperuser | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

Comment (by Tim Graham <timograham@…>):

In [changeset:"33ff4e4e587853ffdcf603419ea0502cf3788c3a" 33ff4e4e]:
{{{
#!CommitTicketReference repository=""
revision="33ff4e4e587853ffdcf603419ea0502cf3788c3a"
[1.11.x] Fixed #27769 -- Documented option naming differences between
django-admin and call_command().

Backport of c8d21f335113dcf6009d7aa9810d4e77dc58c75d from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27769#comment:9>

Reply all
Reply to author
Forward
0 new messages