本文整理匯總了Python中django.forms.fields.BooleanField方法的典型用法代碼示例。如果您正苦於以下問題:Python fields.BooleanField方法的具體用法?Python fields.BooleanField怎麽用?Python fields.BooleanField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.forms.fields
的用法示例。
在下文中一共展示了fields.BooleanField方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_fields
# 需要導入模塊: from django.forms import fields [as 別名]
# 或者: from django.forms.fields import BooleanField [as 別名]
def add_fields(self, form, index):
"""A hook for adding extra fields on to each form instance."""
if self.can_order:
# Only pre-fill the ordering field for initial forms.
if index is not None and index < self.initial_form_count():
form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), initial=index + 1, required=False)
else:
form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), required=False)
if self.can_delete:
form.fields[DELETION_FIELD_NAME] = BooleanField(label=_('Delete'), required=False)
示例2: test_formfield_uses_specified_form_class
# 需要導入模塊: from django.forms import fields [as 別名]
# 或者: from django.forms.fields import BooleanField [as 別名]
def test_formfield_uses_specified_form_class(self):
text_field = self.family_member._meta.get_field('last_name')
form_field = text_field.formfield(form_class=fields.BooleanField)
self.assertTrue(isinstance(form_field, fields.BooleanField))
示例3: is_boolean
# 需要導入模塊: from django.forms import fields [as 別名]
# 或者: from django.forms.fields import BooleanField [as 別名]
def is_boolean(field):
if isinstance(field.field, NullBooleanField):
return False
if isinstance(field.field, BooleanField):
return True
return False
示例4: add_fields
# 需要導入模塊: from django.forms import fields [as 別名]
# 或者: from django.forms.fields import BooleanField [as 別名]
def add_fields(self, form, index):
"""A hook for adding extra fields on to each form instance."""
if self.can_order:
# Only pre-fill the ordering field for initial forms.
if index is not None and index < self.initial_form_count():
form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), initial=index+1, required=False)
else:
form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_('Order'), required=False)
if self.can_delete:
form.fields[DELETION_FIELD_NAME] = BooleanField(label=_('Delete'), required=False)