本文整理汇总了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