class PlaceHolderUserCreationForm(PlaceHolderMixin, UserCreationForm): """Same as auth.forms.UserCreationForm but adds a label as the placeholder in each field""" password1 = fields.PasswordCheckField(label=_("Password")) def __init__(self, *args, **kwargs): super(PlaceHolderUserCreationForm, self).__init__(*args, **kwargs) self.fields["username"].help_text = _("Letters, numbers, and the symbols @/./+/-/_ are allowed.") def clean_username(self): username = self.cleaned_data["username"] validator = validators.ProhibitNullCharactersValidator() validator(username) if get_user_model().objects.filter(username__iexact=username).exists(): raise exceptions.ValidationError(_("A user with that username already exists."), code='duplicate_username') return username
class PlaceHolderPasswordChangeForm(PlaceHolderMixin, PasswordChangeForm): """Same as auth.forms.PasswordChangeForm but adds a label as the placeholder in each field""" new_password1 = fields.PasswordCheckField( label=_("New password"), widget=forms.PasswordInput(attrs={'autocomplete': 'new-password'}), )
class PlaceHolderPasswordChangeForm(PlaceHolderMixin, PasswordChangeForm): """Same as auth.forms.PasswordChangeForm but adds a label as the placeholder in each field""" new_password1 = fields.PasswordCheckField(label=_("New password"))
def setUp(self): self.field = fields.PasswordCheckField()