當前位置: 首頁>>代碼示例>>Python>>正文


Python forms.EmailField方法代碼示例

本文整理匯總了Python中django.forms.EmailField方法的典型用法代碼示例。如果您正苦於以下問題:Python forms.EmailField方法的具體用法?Python forms.EmailField怎麽用?Python forms.EmailField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.forms的用法示例。


在下文中一共展示了forms.EmailField方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_field_kind

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def get_field_kind(field):
  if field['kind'] == 'string':
    return forms.CharField(max_length=255, required=False)
  elif field['kind'] == 'email':
    return forms.EmailField(max_length=255, required=False)
  elif field['kind'] == 'integer':
    return forms.IntegerField(required=False)
  elif field['kind'] == 'boolean':
    return forms.BooleanField(required=False)
  elif field['kind'] == 'text':
    return forms.CharField(widget=forms.Textarea(), required=False)
  elif field['kind'] == 'choice':
    return forms.ChoiceField(choices=map(lambda c: (c,c), field['choices']))
  elif field['kind'] == 'timezones':
    return TimezoneField()
  elif field['kind'] == 'authentication':
    return SwitchField('user', 'service', required=True)
  elif field['kind'] == 'json':
    return JsonField(required=False)
  elif field['kind'] == 'integer_list':
    return CommaSeparatedIntegerField(required=False)
  elif field['kind'] == 'string_list':
    return CommaSeparatedCharField(required=False)
  else:
    return forms.CharField(max_length=255, required=False) 
開發者ID:google,項目名稱:starthinker,代碼行數:27,代碼來源:forms_json.py

示例2: __init__

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
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.'),
            }) 
開發者ID:nlhkabu,項目名稱:connect,代碼行數:23,代碼來源:forms.py

示例3: __init__

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def __init__(self, event=None, *args, **kwargs):
        super(DonationEntryForm, self).__init__(*args, **kwargs)
        minDonationAmount = (
            event.minimumdonation if event is not None else Decimal('1.00')
        )
        self.fields['amount'] = forms.DecimalField(
            decimal_places=2,
            min_value=minDonationAmount,
            max_value=Decimal('100000'),
            label='Donation Amount (min ${0})'.format(minDonationAmount),
            widget=tracker.widgets.NumberInput(
                attrs={
                    'id': 'iDonationAmount',
                    'min': str(minDonationAmount),
                    'step': '0.01',
                }
            ),
            required=True,
        )
        self.fields['comment'] = forms.CharField(widget=forms.Textarea, required=False)
        self.fields['requestedvisibility'] = forms.ChoiceField(
            initial='CURR',
            choices=models.Donation._meta.get_field('requestedvisibility').choices,
            label='Name Visibility',
        )
        self.fields['requestedalias'] = forms.CharField(
            max_length=32, label='Preferred Alias', required=False
        )
        self.fields['requestedemail'] = forms.EmailField(
            max_length=128, label='Preferred Email', required=False
        )
        self.fields['requestedsolicitemail'] = forms.ChoiceField(
            initial='CURR',
            choices=models.Donation._meta.get_field('requestedsolicitemail').choices,
            label='Charity Email Opt In',
        ) 
開發者ID:GamesDoneQuick,項目名稱:donation-tracker,代碼行數:38,代碼來源:forms.py

示例4: make_entry_field

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def make_entry_field(self, fieldsubmission=None):
        c = forms.EmailField(required=self.config['required'],
            label=self.config['label'],
            help_text=self.config['help_text'])

        if fieldsubmission:
            c.initial = fieldsubmission.data['info']

        return c 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:11,代碼來源:text.py

示例5: __init__

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def __init__(self, *args, **kwargs):
        # max_length=254 to be compliant with RFCs 3696 and 5321
        kwargs['max_length'] = kwargs.get('max_length', 254)
        super(EmailField, self).__init__(*args, **kwargs) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:6,代碼來源:__init__.py

示例6: deconstruct

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def deconstruct(self):
        name, path, args, kwargs = super(EmailField, self).deconstruct()
        # We do not exclude max_length if it matches default as we want to change
        # the default in future.
        return name, path, args, kwargs 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:7,代碼來源:__init__.py

示例7: formfield

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def formfield(self, **kwargs):
        # As with CharField, this will cause email validation to be performed
        # twice.
        defaults = {
            'form_class': forms.EmailField,
        }
        defaults.update(kwargs)
        return super(EmailField, self).formfield(**defaults) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:10,代碼來源:__init__.py

示例8: formfield

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def formfield(self, **kwargs):
        # As with CharField, this will cause email validation to be performed
        # twice.
        defaults = {
            'form_class': forms.EmailField,
        }
        defaults.update(kwargs)
        return super().formfield(**defaults) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:10,代碼來源:__init__.py

示例9: __init__

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def __init__(self, *args, **kwargs):
        super(UserCreationFormExtended, self).__init__(*args, **kwargs)
        self.fields['email'] = forms.EmailField(
            label=_("E-mail"),
            max_length=75,
        ) 
開發者ID:BirkbeckCTP,項目名稱:janeway,代碼行數:8,代碼來源:forms.py

示例10: formfield

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def formfield(self, **kwargs):
        # As with CharField, this will cause email validation to be performed
        # twice.
        return super().formfield(**{
            'form_class': forms.EmailField,
            **kwargs,
        }) 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:9,代碼來源:__init__.py

示例11: __init__

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def __init__(self, required=True, help_text=None, validators=(), **kwargs):
        self.field = forms.EmailField(
            required=required,
            help_text=help_text,
            validators=validators,
        )
        super().__init__(**kwargs) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:9,代碼來源:field_block.py

示例12: test_email_field

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def test_email_field(self):
        data = self.get_form_field_data("email")
        cls = wsf_fields.EmailField()
        field = cls.get_formfield(data)

        self.assertIsInstance(field, forms.EmailField)
        self.assertIsInstance(field.widget, forms.widgets.EmailInput)
        self.assertEqual(field.label, data["label"])
        self.assertEqual(field.required, data["required"])
        self.assertEqual(field.help_text, data["help_text"])
        self.assertEqual(field.initial, data["default_value"]) 
開發者ID:labd,項目名稱:wagtailstreamforms,代碼行數:13,代碼來源:test_fields.py

示例13: test_should_email_convert_string

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def test_should_email_convert_string():
    assert_conversion(forms.EmailField, String) 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:4,代碼來源:test_converter.py

示例14: get_form_field

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def get_form_field(self, **kwargs):
    """Return a Django form field appropriate for a User property.

    This defaults to a forms.EmailField instance, except if auto_current_user or
    auto_current_user_add is set, in which case None is returned, as such
    'auto' fields should not be rendered as part of the form.
    """
    if self.auto_current_user or self.auto_current_user_add:
      return None
    defaults = {'form_class': forms.EmailField}
    defaults.update(kwargs)
    return super(UserProperty, self).get_form_field(**defaults) 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:14,代碼來源:djangoforms.py

示例15: add_fields

# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import EmailField [as 別名]
def add_fields(self, form, index):
        form.fields["email"] = EmailField(label=email_field_label) 
開發者ID:iguana-project,項目名稱:iguana,代碼行數:4,代碼來源:forms.py


注:本文中的django.forms.EmailField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。