#27769 closed Bug (fixed)
createsuperuser command missing docs about no-input/interactive
Reported by: | Kenny Loveall | Owned by: | Andrew Nester |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | createsuperuser |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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='test@…')" 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").
Change History (9)
comment:1 by , 8 years ago
Component: | Core (Management commands) → Documentation |
---|---|
Summary: | Impossible to call createsuperuser from call_command → createsuperuser command missing docs about no-input/interactive |
Triage Stage: | Unreviewed → Accepted |
Version: | 1.8 → master |
comment:2 by , 8 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
I've added PR for this #PR
comment:3 by , 8 years ago
Patch needs improvement: | set |
---|
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.
comment:5 by , 8 years ago
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).
comment:6 by , 8 years ago
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).
comment:7 by , 8 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Besides the documentation enhancement, #27787 will improve the situation so that call_command()
rejects unexpected options.
The issue stems from the fact that the
--no-input
command line flag is translating to theinteractive
variable which should be used when calling the command throughcall_command
.call_command('createsuperuser', interactive=False, username='test', email='test@example.com')
should then work.The documentation should really be improved in this case (https://docs.djangoproject.com/en/stable/ref/django-admin/#createsuperuser).