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
This commit is contained in:
Adrian Holovaty 2006-03-01 03:26:08 +00:00
parent e8cfcf28e6
commit b2dd439085
1 changed files with 8 additions and 3 deletions

View File

@ -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.