web/lib/django/contrib/auth/forms.py
changeset 29 cc9b7e14412b
parent 0 0d40e90630ef
equal deleted inserted replaced
28:b758351d191f 29:cc9b7e14412b
     9 
     9 
    10 class UserCreationForm(forms.ModelForm):
    10 class UserCreationForm(forms.ModelForm):
    11     """
    11     """
    12     A form that creates a user, with no privileges, from the given username and password.
    12     A form that creates a user, with no privileges, from the given username and password.
    13     """
    13     """
    14     username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
    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)."),
    15         help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
    16         error_message = _("This value must contain only letters, numbers and underscores."))
    16         error_messages = {'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")})
    17     password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
    17     password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
    18     password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput)
    18     password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput,
       
    19         help_text = _("Enter the same password as above, for verification."))
    19 
    20 
    20     class Meta:
    21     class Meta:
    21         model = User
    22         model = User
    22         fields = ("username",)
    23         fields = ("username",)
    23 
    24 
    42         if commit:
    43         if commit:
    43             user.save()
    44             user.save()
    44         return user
    45         return user
    45 
    46 
    46 class UserChangeForm(forms.ModelForm):
    47 class UserChangeForm(forms.ModelForm):
    47     username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
    48     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         help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
    49         error_message = _("This value must contain only letters, numbers and underscores."))
    50         error_messages = {'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")})
    50     
    51 
    51     class Meta:
    52     class Meta:
    52         model = User
    53         model = User
    53 
    54 
    54 class AuthenticationForm(forms.Form):
    55 class AuthenticationForm(forms.Form):
    55     """
    56     """