From 286ce85e45a7356d96f27ee83a4587e5f44c87a9 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 21 May 2010 14:08:49 +0000 Subject: [PATCH] Fixed #13569 -- Fixed createsuperuser management command to work with the new relaxed requirements for usernames. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13297 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../contrib/auth/management/commands/createsuperuser.py | 3 ++- django/contrib/auth/tests/basic.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/django/contrib/auth/management/commands/createsuperuser.py b/django/contrib/auth/management/commands/createsuperuser.py index 32d845daef..aad6489b38 100644 --- a/django/contrib/auth/management/commands/createsuperuser.py +++ b/django/contrib/auth/management/commands/createsuperuser.py @@ -12,7 +12,8 @@ from django.core import exceptions 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 diff --git a/django/contrib/auth/tests/basic.py b/django/contrib/auth/tests/basic.py index f403613475..ffa11d5d0e 100644 --- a/django/contrib/auth/tests/basic.py +++ b/django/contrib/auth/tests/basic.py @@ -66,4 +66,12 @@ Superuser created successfully. 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'!' """