Ticket #3165: createsuperuser.patch

File createsuperuser.patch, 939 bytes (added by Chris Beaven, 18 years ago)

Assuming the validation message should stay the same, here's the fix

  • django/contrib/auth/create_superuser.py

     
    1010import getpass
    1111import os
    1212import sys
     13import re
    1314
     15RE_VALID_USERNAME = re.compile('\w+$')
     16
    1417def createsuperuser(username=None, email=None, password=None):
    1518    """
    1619    Helper function for creating a superuser from the command line. All
     
    4346                username = raw_input(input_msg + ': ')
    4447            if default_username and username == '':
    4548                username = default_username
    46             if not username.isalnum():
     49            if not RE_VALID_USERNAME.match(username):
    4750                sys.stderr.write("Error: That username is invalid. Use only letters, digits and underscores.\n")
    4851                username = None
    4952                continue
Back to Top