class ComposeForm(forms.Form): email_to = forms.EmailField(label="To", widget=EmailInput(attrs={ "size": 76, "class": "form-control" })) email_cc = forms.EmailField( label="CC", required=False, widget=EmailInput(attrs={ "size": 76, "class": "form-control" }), ) email_subject = forms.CharField( required=False, widget=TextInput(attrs={ "placeholder": "Subject", "size": 76, "class": "form-control" }), ) email_message = forms.CharField( required=True, label="", widget=forms.Textarea( attrs={ "rows": 19, "cols": 78, "class": "form-control", "style": "resize: none", }), )
def __init__(self, *args, **kwargs): super(ExtendedUserCreationForm, self).__init__(*args, **kwargs) self.fields['first_name'].widget = EmailInput(attrs={ 'class': 'form-control', 'id': 'first_name' }) self.fields['last_name'].widget = EmailInput(attrs={ 'class': 'form-control', 'id': 'last_name' }) self.fields['username'].widget = TextInput(attrs={ 'class': 'form-control', 'id': 'username' }) self.fields['password1'].widget = PasswordInput(attrs={ 'class': 'form-control', 'id': 'password1' }) self.fields['password2'].widget = PasswordInput(attrs={ 'class': 'form-control', 'id': 'password2' }) self.fields['email'].widget = EmailInput(attrs={ 'class': 'form-control', 'id': 'useremail' })
class SignupForm(UserCreationForm): username = forms.CharField(widget=TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Username', 'autofocus': 'true' })) email = forms.EmailField(widget=EmailInput(attrs={ 'class': 'form-control', 'placeholder': 'Email' })) password1 = forms.CharField(widget=PasswordInput( attrs={ 'class': 'form-control', 'placeholder': 'Password' })) password2 = forms.CharField(widget=PasswordInput( attrs={ 'class': 'form-control', 'placeholder': 'Confirm password' })) class Meta: model = Account fields = ['username', 'email', 'password1', 'password2'] def clean_email(self): email = self.cleaned_data.get('email') username = self.cleaned_data.get('username') if email and Account.objects.filter(email=email).exclude( username=username).exists(): raise forms.ValidationError( u'A user with that email already exists.') return email
class CreateUserForm(UserCreationForm): error_messages = { 'password_mismatch': _('您輸入的兩個密碼並不相符,請再試一次。'), } username = EmailField( label='', widget=EmailInput(attrs={ 'placeholder': 'Email', 'input_prepend_icon': 'cil-user' }), ) password1 = CharField( label='', widget=PasswordInput(attrs={ 'placeholder': 'Password', 'input_prepend_icon': 'cil-lock-locked' }), ) password2 = CharField( label='', widget=PasswordInput( attrs={ 'placeholder': 'Repeat password', 'input_prepend_icon': 'cil-lock-locked' }), )
class Meta: model = Voluntario fields = [ 'cedula', 'nombres', 'apellidos', 'edad', 'sexo', 'fecha_nacimiento', 'convencional', 'celular', 'correo', 'direccion', 'ocupacion', 'carrera', 'institucion', 'idioma', 'fecha_ingreso', 'estado', 'referencia' ] widgets = { 'convencional': NumberInput(), 'celular': NumberInput(), 'fecha_nacimiento': DateInput(attrs={ 'class': 'mdl-color-text--orange', 'type': 'date' }), 'fecha_ingreso': DateInput(attrs={ 'class': 'mdl-color-text--orange', 'type': 'date' }), 'correo': EmailInput(attrs={'type': 'email'}), } help_texts = {'cedula': 'Cedula Ecuatoriana'}
class Meta: model = User fields = ['username', 'email', 'password'] labels = { 'username': '******', 'email': 'Email', 'password': '******', } widgets = { 'username': TextInput( attrs={ 'class': 'form-control input-sm', 'autofocus': 'autofocus', 'placeholder': 'your preferred login (no spaces)' }), 'email': EmailInput( attrs={ 'class': 'form-control input-sm', 'autofocus': 'autofocus', 'placeholder': 'your email' }), 'password': PasswordInput(attrs={ 'class': 'form-control input-sm', 'autofocus': 'autofocus' }) }
class ExtendedUserCreationForm(UserCreationForm): username = forms.TextInput(attrs={'class': 'form-control'}) first_name = forms.TextInput(attrs={'class': 'form-control'}) last_name = forms.TextInput(attrs={'class': 'form-control'}) email =forms.EmailInput(attrs={'class': 'form-control'}) password1 = forms.PasswordInput(attrs={'class': 'form-control'}) password2 = forms.PasswordInput(attrs={'class': 'form-control'}) class meta: model = User fields = UserCreationForm.Meta.fields + ('first_name', 'last_name', 'email',) """ widgets = { 'first_name': Textarea(attrs={'id': 'first_name','rows': 1, 'cols': 30, 'style': 'resize:none;', 'class': 'form-control', 'required onfocus': "setVisibility('100','inline')", 'onBlur': "setVisibility('100','none')"}), 'last_name': Textarea(attrs={'id': 'last_name','rows': 1, 'cols': 30, 'style': 'resize:none;', 'class': "form-control", 'required onfocus': "setVisibility('101','inline')", 'onBlur': "setVisibility('101','none')"}), 'email': EmailInput(attrs={'id': 'useremail','rows': 1, 'cols': 30, 'style': 'resize:none;','class': "form-control", 'required onfocus': "setVisibility('102','inline')", 'onBlur': "setVisibility('102','none')", 'type': 'email'}), 'username': Textarea(attrs={'id': 'username','rows': 1, 'cols': 30, 'style': 'resize:none;','class': "form-control", 'required onfocus': "setVisibility('104','inline')", 'onBlur': "setVisibility('104','none')"}), 'password1': PasswordInput(attrs={'id': 'password1','rows': 1, 'cols': 30, 'style': 'resize:none;','class': "form-control inputPass", 'required onfocus': "setVisibility('106','inline')", 'onBlur': "setVisibility('106','none')"}), 'password2': PasswordInput(attrs={'id': 'password2','rows': 1, 'cols': 30, 'style': 'resize:none;', 'class': "form-control", 'required onfocus': "setVisibility('107','inline')", 'onBlur': "setVisibility('107','none')"}), } def save(self, commit=True): user = super().save(commit=False) user.email = self.cleaned_data['email'] user.first_name = self.cleaned_data['first_name'] user.last_name = self.cleaned_data['last_name'] if commit: user.save() return user
class ContactoForm(forms.Form): nombre = forms.CharField( label="Nombre", required=True, widget=TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Escribe tu nombre' }), min_length=3, max_length=100) email = forms.EmailField( label="Email", required=True, widget=EmailInput(attrs={ 'class': 'form-control', 'placeholder': 'Escribe tu e-mail' }), min_length=3, max_length=100) contenido = forms.CharField(label="Contenido", required=True, widget=forms.Textarea( attrs={ 'class': 'form-control', 'rows': 3, 'placeholder': 'Escribe tu mensaje' }), min_length=10, max_length=1000)
def __init__(self, *args, **kwargs): super(ContactBaseForm, self).__init__(*args, **kwargs) # We wish for some fields to be mandatory on THIS form for field in self.required_fields: self.fields[field].help_text = None self.fields[field].required = True for fieldname in ['email', 'verify_email']: self.fields[fieldname].widget = EmailInput( attrs={ 'class': 'form-control', 'placeholder': self.fields[fieldname].label }) for fieldname in ['name', 'company', 'email', 'phone']: self.fields[fieldname].widget = TextInput( attrs={ 'class': 'form-control', 'placeholder': self.fields[fieldname].label }) self.fields['comments'].widget = Textarea( attrs={ 'class': 'form-control', 'placeholder': self.fields['comments'].label })
class Meta: model = models.User fields = ['username', 'email', 'first_name', 'last_name'] help_texts = {'username': None} labels = { 'username': "******", 'email': "Your email", 'first_name': "Your first name", 'last_name': "Your last name", } widgets = { 'username': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'JSilverhand' }), 'email': EmailInput(attrs={ 'class': 'form-control', 'placeholder': '*****@*****.**' }), 'first_name': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Johnny' }), 'last_name': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Silverhand' }), }
class Meta: model = Inquiry fields = [ 'name', 'phone', 'email', 'message', ] widgets = { 'name': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Name', }), 'phone': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Phone', }), 'email': EmailInput(attrs={ 'class': 'form-control', 'placeholder': 'Email', }), 'message': Textarea(attrs={ 'class': 'form-control', 'placeholder': 'Message', }) }
class Meta: model = User fields = {'username','first_name','last_name','email'} widgets = {'username':TextInput(attrs={'class':'form-control-lg pass', 'placeholder':'Username', 'required':'required'}), 'first_name':TextInput(attrs={'class':'form-control-lg pass', 'placeholder':'First Name', 'required':'required'}), 'last_name':TextInput(attrs={'class':'form-control-lg pass', 'placeholder':'Last Name', 'required':'required'}), 'email': EmailInput(attrs={'class':'form-control-lg pass', 'placeholder':'Email', 'required':'required'}),}
class Meta: model = LandpageContactMessage fields = ['name', 'email', 'phone', 'message'] labels = {} widgets = { 'name': TextInput( attrs={ 'class': u'form-control', 'placeholder': u'Введите Ваше полное имя' }), 'email': EmailInput(attrs={ 'class': u'form-control', 'placeholder': u'Введите Ваш Email' }), 'phone': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Введите Ваш телефон' }), 'comment': Textarea(attrs={ 'class': u'form-control', 'placeholder': u'Введите Ваше сообщение' }), }
class Meta: model = User fields = ('username', 'email', 'first_name', 'last_name') widgets = { 'username': TextInput(attrs={ 'class': 'input', 'placeholder': 'username' }), 'email': EmailInput(attrs={ 'class': 'input', 'placeholder': 'email' }), 'first name': TextInput(attrs={ 'class': 'input', 'placeholder': 'first name' }), 'Last name': TextInput(attrs={ 'class': 'input', 'placeholder': 'last name' }), }
class ExtendedUserCreationForm(UserCreationForm): def __init__(self, *args, **kwargs): super(ExtendedUserCreationForm, self).__init__(*args, **kwargs) self.fields['username'].widget = TextInput(attrs = {'class': 'form-control',}) self.fields['password1'].widget = PasswordInput(attrs = {'class': 'form-control',}) self.fields['password2'].widget = PasswordInput(attrs = {'class': 'form-control',}) class Meta: model = User fields = ('email', 'username', 'password1', 'password2') widgets = { 'email': EmailInput(attrs={'id': 'useremail','rows': 1, 'cols': 30, 'style': 'resize:none;','class': "form-control", 'required onfocus': "setVisibility('102','inline')", 'onBlur': "setVisibility('102','none')", 'type': 'email'}), } def save(self, commit=True): user = super().save(commit=False) user.email = self.cleaned_data['email'] user.first_name = self.cleaned_data['first_name'] user.last_name = self.cleaned_data['last_name'] if commit: user.save() return user
class JoinForm(UserCreationForm): """ Registration """ class Meta: model = User fields = ('email', 'first_name', 'last_name', 'password1', 'password2') email = forms.EmailField( label="Adresse mail", widget=EmailInput(attrs={'class': 'form-control'}), error_messages={ 'required': 'Il faut renseigner un email', 'invalid': 'Cet email est invalid', 'unique': 'Cet email existe déjà.' }) password1 = forms.CharField( label="Mot de passe", widget=PasswordInput(attrs={'class': 'form-control'})) password2 = forms.CharField( label="Confirmation du mot de passe", widget=PasswordInput(attrs={'class': 'form-control'})) first_name = forms.CharField( required=False, label="Prénom (facultatif)", widget=TextInput(attrs={'class': 'form-control'})) last_name = forms.CharField( required=False, label="Nom (facultatif)", widget=TextInput(attrs={'class': 'form-control'}))
class BenjaminUserCreationForm(UserCreationForm): email = EmailField(widget=EmailInput(attrs={ 'class': 'form-control', 'placeholder': 'Email', })) password1 = CharField( label='Password', strip=False, help_text=password_validation.password_validators_help_text_html(), widget=PasswordInput(attrs={ 'class': 'form-control', 'placeholder': 'Password' }), ) password2 = CharField( label='Please type your password again', strip=False, help_text='Enter the same password as before, for verification.', widget=PasswordInput(attrs={ 'class': 'form-control', 'placeholder': 'Confirm Password' }), ) class Meta(UserCreationForm.Meta): model = User fields = ('email', )
def field_to_widget(field): if type(field) is CharField: if field.choices: return Select(attrs={"class": "form-control"}) return TextInput(attrs={"class": "form-control", "rows": 1}) if type(field) is TextField: return Textarea(attrs={"class": "form-control", "rows": 1}) if type(field) is AutoField: return HiddenInput(attrs={"class": "form-control", "rows": 1}) if type(field) is IntegerField or type(field) is FloatField: return NumberInput(attrs={"class": "form-control"}) if type(field) is EmailField: return EmailInput(attrs={"class": "form-control"}) if type(field) is ForeignKey: return Select(attrs={"class": "form-control"}) if type(field) is ManyToManyField: return CheckboxSelectMultiple(attrs={"class": ""}) if type(field) is BooleanField: return CheckboxInput(attrs={"class": "form-control"}) if type(field) is FileField: return FileInput(attrs={"class": "form-control"}) if type(field) is DateField: return DateInput(attrs={"class": "form-control date", "type": "date"}) if type(field) is DateTimeField: return DateTimeInput(attrs={"class": "form-control datetimepicker"}) return TextInput(attrs={"class": "form-control", "rows": 1})
class SignInForm(AuthenticationForm): username = forms.CharField(label='Email', widget=EmailInput()) password = forms.CharField(label='Пароль', widget=PasswordInput()) class Meta: model = User fields = ('email', 'username')
class Meta: model = Persona fields = ('nombre', 'apellido', 'email', 'celular', 'usuario', 'region', 'contraseña', 'contraseñaconfirmar') widgets = { 'nombre': Textarea(attrs={'rows': 1, 'cols': 30, 'style': 'resize:none;', 'id': 'nombre', 'class': 'form-control', 'required onfocus': "setVisibility('100','inline')", 'onBlur': "setVisibility('100','none')", 'onkeyup': "sync()"}), 'apellido': Textarea(attrs={'rows': 1, 'cols': 30, 'style': 'resize:none;', 'id': 'apellido', 'class': "form-control", 'required onfocus': "setVisibility('101','inline')", 'onBlur': "setVisibility('101','none')"}), 'email': EmailInput(attrs={'rows': 1, 'cols': 30, 'style': 'resize:none;', 'id': 'email', 'class': "form-control", 'required onfocus': "setVisibility('102','inline')", 'onBlur': "setVisibility('102','none')", 'type': 'email'}), 'celular': Textarea(attrs={'rows': 1, 'cols': 30, 'style': 'resize:none;', 'id': 'celular', 'class': "form-control", 'required onfocus': "setVisibility('103','inline')", 'onBlur': "setVisibility('103','none')"}), 'usuario': Textarea(attrs={'rows': 1, 'cols': 30, 'style': 'resize:none;', 'id': 'usuario', 'class': "form-control", 'required onfocus': "setVisibility('104','inline')", 'onBlur': "setVisibility('104','none')"}), 'region': Select(attrs={'class': "form-control", 'onfocus': "setVisibility('105','inline')", 'onBlur': "setVisibility('105','none')", 'default': "rm"}), 'contraseña': PasswordInput(attrs={'rows': 1, 'cols': 30, 'style': 'resize:none;', 'id': 'pass', 'class': "form-control inputPass", 'required onfocus': "setVisibility('106','inline')", 'onBlur': "setVisibility('106','none')"}), 'contraseñaconfirmar': PasswordInput(attrs={'rows': 1, 'cols': 30, 'style': 'resize:none;', 'id': 'passconfirm', 'class': "form-control", 'required onfocus': "setVisibility('107','inline')", 'onBlur': "setVisibility('107','none')"}), } labels = { 'nombre': _('Nombre'), 'apellido': _('Apellido'), 'email': _('Correo Electronico'), 'celular': _('Numero Telefonico'), 'usuario': _('Usuario'), 'region': _('Region'), 'contraseña': _('Contraseña'), 'contraseñaconfirmar': _('Confirmar Contraseña'), }
def __init__(self, *args, **kwargs): super(ExtendedUserCreationForm, self).__init__(*args, **kwargs) self.fields['first_name'].widget = TextInput(attrs={ 'class': 'form-control', 'id': 'first_name', 'type': 'hidden' }) self.fields['last_name'].widget = TextInput(attrs={ 'class': 'form-control', 'id': 'last_name', 'type': 'hidden' }) self.fields['username'].widget = TextInput( attrs={ 'class': 'form-control', 'id': 'username', 'required onfocus': "setVisibility('104','inline')", 'onBlur': "setVisibility('104','none')" }) self.fields['password1'].widget = PasswordInput(attrs={ 'class': 'form-control', 'id': 'password1' }) self.fields['password2'].widget = PasswordInput(attrs={ 'class': 'form-control', 'id': 'password2' }) self.fields['email'].widget = EmailInput(attrs={ 'class': 'form-control', 'id': 'useremail', 'type': 'hidden' })
class Meta: model = LandpageContactMessage fields = ['name', 'email', 'phone', 'message'] labels = {} widgets = { 'name': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Full Name' }), 'email': EmailInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Email' }), 'phone': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Phone' }), 'comment': Textarea(attrs={ 'class': u'form-control', 'placeholder': u'Enter Comment' }), }
class EnterTaskForm(forms.Form): ''' Форма для ввода задания ''' url = forms.URLField( label='URL', help_text='Ссылка на раздел сайта www.olx.ua', widget=URLInput(attrs={'class': 'form-control'}), validators=[ validators.RegexValidator( r'^https://www.olx.ua/[a-z\-]{1,}/[a-z\-]{1,}/') ], error_messages={ 'invalid': 'Нужно указать ссылку на существующий раздел сайта olx.ua!' }) email = forms.EmailField( label='E-mail', help_text='Ваш E-mail, на который будет выслана ссылка с отчетом', widget=EmailInput(attrs={'class': 'form-control'})) description = forms.CharField( max_length=250, label='Описание', help_text='Это описание будет использовано в заголовке отчёта', widget=TextInput(attrs={'class': 'form-control'}))
class ContactForm(forms.Form): "this is contact form rendered on contact.html" fullname = forms.CharField(widget=TextInput( attrs={ "class":"form-control", "placeholder":"Your Name" } )) email = forms.EmailField(widget=EmailInput( attrs={ "class":"form-control", "placeholder":"Your Email" } )) content = forms.CharField(widget=Textarea( attrs={ "class":"form-control", "placeholder":"Your Content", "rows":"5" } )) def clean_email(self): email = self.cleaned_data.get('email') if not 'gmail.com' in email: raise forms.ValidationError(f"{ email } is not a valid email") return email
class UserLoginForm(AuthenticationForm): username = EmailField(widget=EmailInput(attrs={ 'class': 'form-input', 'placeholder': _('Email') })) password = CharField( strip=False, widget=PasswordInput(attrs={ 'class': 'from-input', 'placeholder': _('Mot de passe') })) def clean(self): email = self.cleaned_data.get('email') password = self.cleaned_data.get('password') if email is None and password: raise forms.ValidationError( _("Veuillez entrer un email ainsi qu'un mot de passe")) if email and password: self.user_cache = authenticate(self.request, email=email, password=password) if self.user_cache: self.confirm_login_allowed(self.user_cache) return self.cleaned_data
class DashboardSignupForm(forms.Form): nom = forms.CharField(widget=TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Nom' })) prenom = forms.CharField(widget=TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Prénom' })) email = forms.CharField(widget=EmailInput(attrs={ 'class': 'form-control', 'placeholder': 'Email' })) password = forms.CharField(widget=PasswordInput(attrs={ 'class': 'form-control', 'placeholder': 'Email' })) token = forms.CharField(widget=TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Token' })) def clean(self): token = self.cleaned_data['token'] password = self.cleaned_data['password'] if len(password) < 10: raise forms.ValidationError( 'Le mot de passe doit être supérieur à 10 charactères') if token != 'gloria': raise forms.ValidationError("Le token n'est pas valide") return dict(name=self.cleaned_data['nom'], surname=self.cleaned_data['prenom'], \ email=self.cleaned_data['email'], password=self.cleaned_data['password'])
class SubscriptionForm(forms.ModelForm): email = forms.EmailField(widget=EmailInput( attrs={'placeholder': 'Enter email address'})) class Meta: model = MailSubscription fields = "__all__"
class SignUpForm(UserCreationForm): username = forms.CharField( max_length=250, widget=TextInput(attrs={ 'placeholder':'Username', 'class':'form-control' }) ) first_name = forms.CharField( max_length=250, widget=TextInput(attrs={ 'placeholder':'First Name', 'class':'form-control' }) ) last_name = forms.CharField( max_length=250, widget=TextInput(attrs={ 'placeholder':'Last Name', 'class':'form-control' }) ) email = forms.EmailField( max_length=250, widget=EmailInput(attrs={ 'placeholder':'Email', 'class':'form-control' }) ) password1 = forms.CharField( max_length=250, widget=PasswordInput(attrs={ 'placeholder':'Password', 'class':'form-control' }) ) password2 = forms.CharField( max_length=250, widget=PasswordInput(attrs={ 'placeholder':'Confirm Password', 'class':'form-control' }) ) class Meta: model = User fields = ('username','first_name','last_name','email','password1','password2') def save(self,commit=True): user = super(SignUpForm,self).save(commit=False) #user.username = cleaned_data['username'] #user.first_name = cleaned_data['first_name'] #user.last_name = cleaned_data['last_name'] #user.email = cleaned_data['email'] if commit: user.save() return user
def __init__(self, attrs=None, email_attrs=None, code_attrs=None, **context): self.context = context widgets = (EmailInput(attrs=email_attrs), TextInput(attrs=code_attrs)) super(VerifiedEmailWidget, self).__init__(widgets, attrs)
class CustomLoginForm(AuthenticationForm): username = forms.CharField(widget=EmailInput(attrs={ 'class': 'validate', 'placeholder': 'Email' })) password = forms.CharField(widget=PasswordInput( attrs={'placeholder': 'Password'})) '''email = forms.CharField(widget=TextInput(attrs={'class':'validate','placeholder': 'Email'}))