Fixed #7423 -- Skip user creation when not in a TTY. #2304

Closed
wants to merge 2 commits into from

2 participants

@AeroNotix

Thanks to galaxy4sale for the report.

@bmispelon bmispelon commented on an outdated diff Feb 16, 2014
...o/contrib/auth/management/commands/createsuperuser.py
@@ -135,9 +142,18 @@ def handle(self, *args, **options):
except KeyboardInterrupt:
self.stderr.write("\nOperation cancelled.")
sys.exit(1)
-
- user_data[self.UserModel.USERNAME_FIELD] = username
- user_data['password'] = password
- self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
- if verbosity >= 1:
- self.stdout.write("Superuser created successfully.")
+ except NotRunningInTTYException:
+ self.stdout.write(
+ "Superuser creation skipped due to not running in a shell."
+ " You can run `createsuperuser` in your shell in your"
@bmispelon
Django member
Superuser creation skipped due to not running in a TTY. You can run `manage.py createsuperuser` in your project to create one manually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@bmispelon bmispelon commented on an outdated diff Feb 16, 2014
django/core/management/base.py
@@ -306,6 +306,7 @@ def execute(self, *args, **options):
self.stderr = OutputWrapper(options.get('stderr', sys.stderr))
else:
self.stderr = OutputWrapper(options.get('stderr', sys.stderr), self.style.ERROR)
+ self.stdin = options.get('stdin', sys.stdin)
@bmispelon
Django member

If this is going to be left undocumented, I'd add a comment here that this is used for testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@bmispelon
Django member

Can you add a short test to make sure that BaseCommand.stdin exists and is set correctly (that it defaults to sys.stdin when nothing is passed)

@AeroNotix

@bmispelon sorted the first two, working on a test for passing stdin now.

@bmispelon
Django member

Merged in a763972.

Thanks!

@bmispelon bmispelon closed this Feb 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment