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.
* 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>
* 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>
* 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>
* needs_better_patch: 1 => 0
Comment:
I've updated my PR according to comments.
--
Ticket URL: <https://code.djangoproject.com/ticket/27769#comment:4>
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>
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>
* 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>
* 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>
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>