From b2dd439085fb300a4ce0d921a268d22f5b696486 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Wed, 1 Mar 2006 03:26:08 +0000 Subject: [PATCH] magic-removal: Fixed #1405 -- 'createsuperuser' no longer assumes 'import pwd' will work. Thanks, anonymous git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2452 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/django/core/management.py b/django/core/management.py index f6552d0343..cc0b0abde0 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -660,10 +660,15 @@ def createsuperuser(username=None, email=None, password=None): "Creates a superuser account." from django.core import validators from django.contrib.auth.models import User - import getpass, pwd + import getpass - # Determine the current system user's username, to use as a default. - default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower() + try: + import pwd + except ImportError: + default_username = '' + else: + # Determine the current system user's username, to use as a default. + default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower() # Determine whether the default username is taken, so we don't display # it as an option.