class CustomInfo(UserCreationForm): email = forms.EmailField( max_length=50, help_text='Required. Inform a valid email address.', widget=forms.EmailInput(attrs={ 'placeholder': 'Email', "class": "inpt", }), ) password1 = forms.CharField( label=_('Password'), widget=(forms.PasswordInput(attrs={ 'placeholder': 'Password', })), help_text=password_validation.password_validators_help_text_html()) password2 = forms.CharField( label=_('Password Confirmation'), widget=forms.PasswordInput( attrs={'placeholder': 'Password Confirmation'}), help_text=_('Just Enter the same password, for confirmation')) username = forms.CharField( label=_('Username'), max_length=150, help_text= _('Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.' ), validators=[username_validator], error_messages={ 'unique': _("A user with that username already exists.") }, widget=forms.TextInput(attrs={'placeholder': 'Username'})) class Meta: model = User fields = ["username", "email", "password1", "password2"]
class RegistrationForm(forms.Form): username = forms.CharField(label='Username', max_length=20, min_length=1) password1 = forms.CharField(label='Password', widget=forms.PasswordInput(), max_length=15, min_length=3) password2 = forms.CharField(label='Password (Again)', widget=forms.PasswordInput(), max_length=15, min_length=3) mobileNo = forms.CharField(label='Mobile No.', max_length=15, min_length=5) email = forms.EmailField(label='Email') def clean_password2(self): if 'password1' in self.cleaned_data: password1 = self.cleaned_data['password1'] password2 = self.cleaned_data['password2'] if password1 == password2: return password2 raise forms.ValidationError('Passwords do not match.') def clean_username(self): username = self.cleaned_data['username'] if not re.search(r'^\w+$', username): raise forms.ValidationError( 'Username can only containalphanumericcharacters and the underscore.' ) try: Register.objects.get(name=username) except ObjectDoesNotExist: return username raise forms.ValidationError('Username is already taken.')
class CreateUserForm(UserCreationForm): error_messages = { 'password_mismatch': _('Пароли не совпадают.'), } password1 = forms.CharField( label=_("Пароль"), strip=False, widget=forms.PasswordInput(attrs={'autocomplete': 'new-password'}), help_text="Придумайте свой пароль", ) password2 = forms.CharField( label=_("Подтверждение пароля"), widget=forms.PasswordInput(attrs={'autocomplete': 'new-password'}), strip=False, help_text=_("Введите пароль повторно"), ) class Meta: model = User fields = ("username", 'email', 'first_name', 'last_name') field_classes = { 'username': UsernameField, 'email': forms.EmailField, 'first_name': forms.CharField, 'last_name': forms.CharField }
class UserForm(ModelForm): usuario = forms.CharField(max_length=50) nombre = forms.CharField(max_length=20) apellido = forms.CharField(max_length=20) email = forms.EmailField() contrasena = forms.CharField(widget=forms.PasswordInput()) contrasena2 = forms.CharField(widget=forms.PasswordInput()) class Meta: model = CustomUser fields = ['pais', 'ciudad', 'imagen'] def clean_username(self): username = self.cleaned_data['usuario'] if User.objects.filter(username=username): raise forms.ValidationError('Nombre de usuario ya registrado.') return username def clean_email(self): email = self.cleaned_data['email'] if User.objects.filter(email=email): raise forms.ValidationError('Ya existe un email igual registrado.') return email def clean_password2(self): password = self.cleaned_data['contrasena'] password2 = self.cleaned_data['contrasena'] if password != password2: raise forms.ValidationError('Las claves no coinciden') return password2 def __unicode__(self): return self.name
class SignUpForm(UserCreationForm): first_name = forms.CharField( max_length=12, min_length=4, required=True, help_text='Required: First Name', widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'First Name' })) last_name = forms.CharField( max_length=12, min_length=4, required=True, help_text='Required: Last Name', widget=(forms.TextInput(attrs={'class': 'form-control'}))) email = forms.EmailField( max_length=50, help_text='Required. Inform a valid email address.', widget=forms.EmailInput(attrs={'placeholder': 'Email'}), ) password1 = forms.CharField( label=_('Password'), widget=(forms.PasswordInput(attrs={ 'placeholder': 'Password', })), help_text=password_validation.password_validators_help_text_html()) password2 = forms.CharField( label=_('Password Confirmation'), widget=forms.PasswordInput( attrs={'placeholder': 'Password Confirmation'}), help_text=_('Just Enter the same password, for confirmation')) username = forms.CharField( label=_('Username'), max_length=150, help_text= _('Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.' ), validators=[username_validator], error_messages={ 'unique': _("A user with that username already exists.") }, widget=forms.TextInput(attrs={'placeholder': 'Username'})) class Meta: model = User fields = ( 'username', 'first_name', 'last_name', 'email', 'password1', 'password2', )
class UserSetPasswordForm(SetPasswordForm): new_password1 = forms.CharField( label=_("New password"), widget=forms.PasswordInput( attrs={'autocomplete': 'new-password', 'class': 'form-control'}), strip=False, ) new_password2 = forms.CharField( label=_("New password confirmation"), strip=False, widget=forms.PasswordInput( attrs={'autocomplete': 'new-password', 'class': 'form-control'}), )
class LoginForm(AuthenticationForm): username = UsernameField(widget=forms.TextInput( attrs={'autofocus': True, 'class': 'form-control'})) password = forms.CharField( label=_("Password"), strip=False, widget=forms.PasswordInput( attrs={'autocomplete': 'current-password', 'class': 'form-control'}), ) error_messages = { 'invalid_login': _( "Please enter a correct %(username)s and password. Note that both " "fields may be case-sensitive." ), 'inactive': _("This account is not verified."), } def __init__(self, request=None, *args, **kwargs): """ The 'request' parameter is set for custom auth use by subclasses. The form data comes in via the standard 'data' kwarg. """ self.request = request self.user_cache = None super().__init__(*args, **kwargs)
class LoginForm(forms.Form): username = forms.CharField( max_length=63, widget=forms.TextInput(attrs={'placeholder': 'USERNAME'})) password = forms.CharField( max_length=63, widget=forms.PasswordInput(attrs={'placeholder': 'PASSWORD'})) class Meta: model = User fields = ["username", "password"]
class UserChangePasswordForm(PasswordChangeForm): old_password = forms.CharField( label=_("Old password"), strip=False, widget=forms.PasswordInput( attrs={'autocomplete': 'current-password', 'autofocus': True, 'class': 'form-control'}), ) new_password1 = forms.CharField( label=_("New password"), widget=forms.PasswordInput( attrs={'autocomplete': 'new-password', 'class': 'form-control'}), strip=False, ) new_password2 = forms.CharField( label=_("New password confirmation"), strip=False, widget=forms.PasswordInput( attrs={'autocomplete': 'new-password', 'class': 'form-control'}), ) field_order = ['old_password', 'new_password1', 'new_password2']
class BootstrapAuthenticationForm(AuthenticationForm): """Authentication form which uses boostrap CSS.""" username = forms.CharField(max_length=254, widget=forms.TextInput({ 'class': 'form-control', 'placeholder': 'User Name' })) password = forms.CharField(label=_("Password"), widget=forms.PasswordInput({ 'class': 'form-control', 'placeholder': 'Password' }))
class loginForm(forms.Form): username = forms.CharField(max_length=30, ) password = forms.CharField(max_length=30, widget=forms.PasswordInput())
class SignupForm(UserCreationForm): username = forms.CharField(max_length=254, widget=forms.TextInput({ 'class': 'form-control', 'placeholder': 'Username' })) first_name = forms.CharField(max_length=30, required=False, help_text='Optional.', widget=forms.TextInput({ 'class': 'form-control', 'placeholder': 'First Name' })) last_name = forms.CharField(max_length=30, required=False, help_text='Optional.', widget=forms.TextInput({ 'class': 'form-control', 'placeholder': 'Last Name' })) email = forms.EmailField(max_length=254, required=True, widget=forms.TextInput({ 'class': 'form-control', 'placeholder': 'Email address' })) password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput({ 'class': 'form-control', 'placeholder': 'Create password' })) password2 = forms.CharField(label=_("Password"), widget=forms.PasswordInput({ 'class': 'form-control', 'placeholder': 'Repeat password' })) class Meta: model = User fields = ( 'username', 'first_name', 'last_name', 'email', 'password1', 'password2', ) def clean_email(self): # Get the email email = self.cleaned_data.get('email') # Check to see if any users already exist with this email as a username. try: match = User.objects.get(email=email) except User.DoesNotExist: # Unable to find a user, this is fine return email # A user was found with this as a username, raise an error. raise forms.ValidationError( 'This email address is already in use.')