Python django.forms.EmailInput() Examples

The following are 3 code examples of django.forms.EmailInput(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.forms , or try the search function .
Example #1
Source File: forms.py    From freedomvote with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, *args, **kwargs):
        kwargs.setdefault('label_suffix', '')
        super(PoliticianForm, self).__init__(*args, **kwargs)
        for field_name, field in self.fields.items():
            if isinstance(field.widget, forms.TextInput) or isinstance(field.widget, forms.Select) or isinstance(field.widget, forms.EmailInput):
                field.widget.attrs.update({
                    'class': 'form-control'
                })
            if field_name == 'party':
                field.choices = [('', '---------')]
                field.choices += [
                    (p.id, p.name)
                    for p
                    in Party.objects.order_by('name')
                ]

            if isinstance(field.widget, forms.Textarea):
                field.widget.attrs.update({
                    'class': 'form-control',
                    'rows': 2,
                }) 
Example #2
Source File: forms.py    From connect with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user', None)
        super(UpdateEmailForm, self).__init__(*args, **kwargs)

        self.fields['email'] = forms.EmailField(
            initial=self.user.email,
            widget=forms.EmailInput(attrs={
                'placeholder': _('Email')
            }),
            error_messages={
                'required': _('Please enter your new email address.'),
                'invalid': _('Please enter a valid email address.')
            })

        self.fields['password'] = forms.CharField(
            widget=forms.PasswordInput(attrs={
                'placeholder': _('Password')
            }),
            error_messages={
                'required': _('Please enter your password.'),
            }) 
Example #3
Source File: forms.py    From djangocms-forms with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def prepare_email(self, field):
        field_attrs = field.build_field_attrs()
        widget_attrs = field.build_widget_attrs(extra_attrs={'autocomplete': 'email'})

        field_attrs.update({
            'widget': forms.EmailInput(attrs=widget_attrs),
        })
        return forms.EmailField(**field_attrs)