Ticket #5786: django-auth-username-characters-round2.patch

File django-auth-username-characters-round2.patch, 2.5 KB (added by Luis Bruno, 14 years ago)

add to alextreme's patch: change models.py help_text

  • models.py

     
    125125
    126126    Username and password are required. Other fields are optional.
    127127    """
    128     username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
     128    username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters"))
    129129    first_name = models.CharField(_('first name'), max_length=30, blank=True)
    130130    last_name = models.CharField(_('last name'), max_length=30, blank=True)
    131131    email = models.EmailField(_('e-mail address'), blank=True)
  • forms.py

     
    1111    """
    1212    A form that creates a user, with no privileges, from the given username and password.
    1313    """
    14     username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
    15         help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
    16         error_message = _("This value must contain only letters, numbers and underscores."))
     14    username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
     15        help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
     16        error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters."))
    1717    password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
    1818    password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput)
    1919
     
    4444        return user
    4545
    4646class UserChangeForm(forms.ModelForm):
    47     username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
    48         help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
    49         error_message = _("This value must contain only letters, numbers and underscores."))
     47    username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
     48        help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
     49        error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters."))
    5050   
    5151    class Meta:
    5252        model = User
Back to Top