本文整理匯總了Python中django.forms.boundfield.BoundField方法的典型用法代碼示例。如果您正苦於以下問題:Python boundfield.BoundField方法的具體用法?Python boundfield.BoundField怎麽用?Python boundfield.BoundField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.forms.boundfield
的用法示例。
在下文中一共展示了boundfield.BoundField方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: label_tag
# 需要導入模塊: from django.forms import boundfield [as 別名]
# 或者: from django.forms.boundfield import BoundField [as 別名]
def label_tag(self, contents=None, attrs=None, label_suffix=None):
classes = []
if not contents:
contents = mark_safe(conditional_escape(force_text(self.label)))
if self.is_checkbox:
classes.append('vCheckboxLabel')
if self.field.required:
classes.append('required')
if not self.is_first:
classes.append('inline')
attrs = {'class': ' '.join(classes)} if classes else {}
# checkboxes should not have a label suffix as the checkbox appears
# to the left of the label.
return super(BoundField, self).label_tag(
contents=contents, attrs=attrs,
label_suffix='' if self.is_checkbox else None
)
示例2: get_bound_field
# 需要導入模塊: from django.forms import boundfield [as 別名]
# 或者: from django.forms.boundfield import BoundField [as 別名]
def get_bound_field(self, form, field_name):
"""
Return a BoundField instance that will be used when accessing the form
field in a template.
"""
return BoundField(form, self, field_name)