              help='Specifies the username for the superuser.'),
          make_option('--email', dest='email', default=None,
              help='Specifies the email address for the superuser.'),
          make_option('--noinput', action='store_false', dest='interactive', default=True,
              help='Tells Django to NOT prompt the user for input of any kind. '    \
                   'You must use --username and --email with --noinput, and '      \
                   'superusers created with --noinput will not be able to log in '  \
                   'until they\'re given a valid password.'),
      )
      help = 'Used to create a superuser.'
  
      def handle(self, *args, **options):
          username = options.get('username', None)
 
</s> remove             import pwd
            default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower()
 </s> add             default_username = getpass.getuser().replace(' ', '').lower() </s> remove             # KeyError will be raised by getpwuid() if there is no
            # corresponding entry in the /etc/passwd file (a very restricted
            # chroot environment, for example).
 </s> add             # KeyError will be raised by os.getpwuid() (called by getuser())
            # if there is no corresponding entry in the /etc/passwd file
            # (a very restricted chroot environment, for example). </s> remove import os
 </s> add 
            help=('Tells Django to NOT prompt the user for input of any kind. '
                  'You must use --username and --email with --noinput, and '
                  'superusers created with --noinput will not be able to log '
                  'in until they\'re given a valid password.')),
              help='Specifies the username for the superuser.'),
          make_option('--email', dest='email', default=None,
              help='Specifies the email address for the superuser.'),
          make_option('--noinput', action='store_false', dest='interactive', default=True,
            help=('Tells Django to NOT prompt the user for input of any kind. '
                  'You must use --username and --email with --noinput, and '
                  'superusers created with --noinput will not be able to log '
                  'in until they\'re given a valid password.')),
            help=('Tells Django to NOT prompt the user for input of any kind. '
                  'You must use --username and --email with --noinput, and '
                  'superusers created with --noinput will not be able to log '
                  'in until they\'re given a valid password.')),
            help=('Tells Django to NOT prompt the user for input of any kind. '
                  'You must use --username and --email with --noinput, and '
                  'superusers created with --noinput will not be able to log '
                  'in until they\'re given a valid password.')),
            help=('Tells Django to NOT prompt the user for input of any kind. '
                  'You must use --username and --email with --noinput, and '
                  'superusers created with --noinput will not be able to log '
                  'in until they\'re given a valid password.')),
      )
      help = 'Used to create a superuser.'
  
      def handle(self, *args, **options):
          username = options.get('username', None)
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Fixed #7077 and #7431 -- Use getpass.getuser instead of pwd.getpwuid to determine the current system user's username in the createsuperuser management command to enable the feature on Windows. getpass.getuser automatically falls back to the previous method.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14607 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/contrib/auth/management/commands/createsuperuser.py