本文整理汇总了Python中django.forms.forms.BoundField.value方法的典型用法代码示例。如果您正苦于以下问题:Python BoundField.value方法的具体用法?Python BoundField.value怎么用?Python BoundField.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms.forms.BoundField
的用法示例。
在下文中一共展示了BoundField.value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from django.forms.forms import BoundField [as 别名]
# 或者: from django.forms.forms.BoundField import value [as 别名]
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
extra = []
for field in self.fields:
field_instance = form.fields[field]
bound_field = BoundField(form, field_instance, field)
extra.append(bound_field.value())
context["extra"] = mark_safe("\n".join(extra))
return super(VisibleHiddenField, self).render(form, form_style, context, template_pack)
示例2: format_as_pml
# 需要导入模块: from django.forms.forms import BoundField [as 别名]
# 或者: from django.forms.forms.BoundField import value [as 别名]
def format_as_pml(self):
output = []
for name, field in self.fields.items():
bf = BoundField(self, field, name)
text_field_type = 'Text'
if(isinstance(field, IntegerField)):
text_field_type = 'num'
field_str = ('<TEXT position="ABOVE">%(label_name)s</TEXT><FIELD name="%(field_name)s" type="%(text_field_type)s" default="%(field_value)s"/><br/>'
% {
'label_name': conditional_escape(force_unicode(bf.label)),
'field_name': bf.html_name,
'field_value': bf.value() if bf.value() != None else '',
'text_field_type': text_field_type
})
if(isinstance(field, BooleanField)):
default = bf.value() if bf.value() != None else ''
field_str = ('''<CHOICE-GROUP type="radio" name="%(field_name)s">
<TEXT>%(label_name)s</TEXT>
<CHOICE value="True" %(default_true)s>Yes</CHOICE>
<CHOICE value="False" %(default_false)s>No</CHOICE>
</CHOICE-GROUP>''' %
{
'default_true': 'checked="true"' if default else '',
'default_false': 'checked="true"' if not default else '',
'label_name': conditional_escape(force_unicode(bf.label)),
'field_name': bf.html_name,
'field_value': bf.value() if bf.value() != None else ''
})
output.append(field_str)
return mark_safe(u'\n'.join(output))