Ticket #11127: regex.diff

File regex.diff, 852 bytes (added by Richard Davies <richard.davies@…>, 15 years ago)

Use regex in AuthenticationForm too

  • django/contrib/auth/forms.py

     
    5656    Base class for authenticating users. Extend this to get a form that accepts
    5757    username/password logins.
    5858    """
    59     username = forms.CharField(label=_("Username"), max_length=30)
     59    username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
     60        help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
     61        error_message = _("This value must contain only letters, numbers and underscores."))
    6062    password = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
    6163
    6264    def __init__(self, request=None, *args, **kwargs):
Back to Top