Ticket #9541: 9541-r9368-wider-choice-of-username.diff

File 9541-r9368-wider-choice-of-username.diff, 3.4 KB (added by Richard Davies <richard.davies@…>, 16 years ago)
  • django/contrib/auth/models.py

     
    124124
    125125    Username and password are required. Other fields are optional.
    126126    """
    127     username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
     127    username = models.CharField(_('username'), max_length=36, unique=True, help_text=_("Required. 36 characters or fewer. Alphanumeric characters only (letters, digits, underscores and hyphens)."))
    128128    first_name = models.CharField(_('first name'), max_length=30, blank=True)
    129129    last_name = models.CharField(_('last name'), max_length=30, blank=True)
    130130    email = models.EmailField(_('e-mail address'), blank=True)
  • django/contrib/auth/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=36, regex=r'^[\w-]+$',
     15        help_text = _("Required. 36 characters or fewer. Alphanumeric characters only (letters, digits, underscores and hyphens)."),
     16        error_message = _("This value must contain only letters, numbers, underscores and hyphens."))
    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=36, regex=r'^[\w-]+$',
     48        help_text = _("Required. 36 characters or fewer. Alphanumeric characters only (letters, digits, underscores and hyphens)."),
     49        error_message = _("This value must contain only letters, numbers, underscores and hyphens."))
    5050   
    5151    class Meta:
    5252        model = User
     
    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=36, regex=r'^[\w-]+$',
     60        help_text = _("Required. 36 characters or fewer. Alphanumeric characters only (letters, digits, underscores and hyphens)."),
     61        error_message = _("This value must contain only letters, numbers, underscores and hyphens."))
    6062    password = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
    6163
    6264    def __init__(self, request=None, *args, **kwargs):
Back to Top