Commits

Anonymous committed f151991

Fixed #13569 -- Fixed createsuperuser management command to work with the new relaxed requirements for usernames.

Comments (0)

Files changed (2)

django/contrib/auth/management/commands/createsuperuser.py

 from django.core.management.base import BaseCommand, CommandError
 from django.utils.translation import ugettext as _
 
-RE_VALID_USERNAME = re.compile('\w+$')
+RE_VALID_USERNAME = re.compile('[\w.@+-]+$')
+
 EMAIL_RE = re.compile(
     r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*"  # dot-atom
     r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"' # quoted-string

django/contrib/auth/tests/basic.py

 u'joe@somewhere.org'
 >>> u.password
 u'!'
+>>> call_command("createsuperuser", interactive=False, username="joe+admin@somewhere.org", email="joe@somewhere.org")
+Superuser created successfully.
+
+>>> u = User.objects.get(username="joe+admin@somewhere.org")
+>>> u.email
+u'joe@somewhere.org'
+>>> u.password
+u'!'
 """