Ticket #722: username.patch
File username.patch, 1.9 KB (added by , 18 years ago) |
---|
-
django/core/validators.py
29 29 phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE) 30 30 slug_re = re.compile(r'^[-\w]+$') 31 31 url_re = re.compile(r'^https?://\S+$') 32 username_re = re.compile(r'^[-\w.@+]+$') 32 33 33 34 lazy_inter = lazy(lambda a,b: str(a) % b, str) 34 35 … … 58 59 def __str__(self): 59 60 return str(self.messages) 60 61 62 def isUserName(field_data, all_data): 63 if not username_re.search(field_data): 64 raise ValidationError, "This value must contain only letters, numbers and underscores, dashes, . and @." 65 61 66 def isAlphaNumeric(field_data, all_data): 62 67 if not alnum_re.search(field_data): 63 68 raise ValidationError, gettext("This value must contain only letters, numbers and underscores.") -
django/contrib/auth/models.py
87 87 88 88 Username and password are required. Other fields are optional. 89 89 """ 90 username = models.CharField(_('username'), maxlength=30, unique=True, validator_list=[validators.is AlphaNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))90 username = models.CharField(_('username'), maxlength=30, unique=True, validator_list=[validators.isUserName], help_text=_("Required. 30 characters or fewer. Letters, digits, dash, period, @ and underscores.")) 91 91 first_name = models.CharField(_('first name'), maxlength=30, blank=True) 92 92 last_name = models.CharField(_('last name'), maxlength=30, blank=True) 93 93 email = models.EmailField(_('e-mail address'), blank=True)