本文整理匯總了Python中django.forms.forms.BoundField方法的典型用法代碼示例。如果您正苦於以下問題:Python forms.BoundField方法的具體用法?Python forms.BoundField怎麽用?Python forms.BoundField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.forms.forms
的用法示例。
在下文中一共展示了forms.BoundField方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: css_class
# 需要導入模塊: from django.forms import forms [as 別名]
# 或者: from django.forms.forms import BoundField [as 別名]
def css_class(field):
if isinstance(field, BoundField):
field = field.field
return field.widget.__class__.__name__.lower()
示例2: is_disabled
# 需要導入模塊: from django.forms import forms [as 別名]
# 或者: from django.forms.forms import BoundField [as 別名]
def is_disabled(field):
if isinstance(field, BoundField):
field = field.field
return 'disabled' in field.widget.attrs
示例3: is_readonly
# 需要導入模塊: from django.forms import forms [as 別名]
# 或者: from django.forms.forms import BoundField [as 別名]
def is_readonly(field):
if isinstance(field, BoundField):
field = field.field
return ('readonly' in field.widget.attrs and
field.widget.attrs.get('readonly') is True)
示例4: value
# 需要導入模塊: from django.forms import forms [as 別名]
# 或者: from django.forms.forms import BoundField [as 別名]
def value(self):
"""
Returns the form/formset for this BoundField. This is passed into the
call for ``self.widget.render`` in the ``as_widget`` method.
"""
return self.form.get_composite_field_value(self.name)
# label_tag, no changes required
# auto_id, no changes required
# id_for_label, no changes required
示例5: test_it_iterates_over_form_fields
# 需要導入模塊: from django.forms import forms [as 別名]
# 或者: from django.forms.forms import BoundField [as 別名]
def test_it_iterates_over_form_fields(self):
form = AccountForm()
composite_bf = form['nested_form']
for nested_bf in composite_bf:
self.assertTrue(isinstance(nested_bf, BoundField))
self.assertEqual(nested_bf.name, 'name')
示例6: test_it_allows_key_access_to_form_fields
# 需要導入模塊: from django.forms import forms [as 別名]
# 或者: from django.forms.forms import BoundField [as 別名]
def test_it_allows_key_access_to_form_fields(self):
form = AccountForm()
composite_f = form['nested_form']
nested_bf = composite_f['name']
self.assertTrue(isinstance(nested_bf, BoundField))
self.assertEqual(nested_bf.name, 'name')
示例7: as_bootstrap
# 需要導入模塊: from django.forms import forms [as 別名]
# 或者: from django.forms.forms import BoundField [as 別名]
def as_bootstrap(form_or_field, layout='vertical,false'):
"""
Render a field or a form according to Bootstrap guidelines
"""
params = split(layout, ",")
layout = str(params[0]).lower()
try:
bootstrap_float = str(params[1]).lower() == "float"
except IndexError:
bootstrap_float = False
if isinstance(form_or_field, BaseForm):
return render_to_string("bootstrap_toolkit/form.html", context={
'form': form_or_field,
'layout': layout,
'float': bootstrap_float,
}
)
elif isinstance(form_or_field, BoundField):
return render_to_string("bootstrap_toolkit/field.html", context={
'field': form_or_field,
'layout': layout,
'float': bootstrap_float,
}
)
else:
# Display the default
return settings.TEMPLATE_STRING_IF_INVALID