本文整理汇总了Python中django.forms.widgets.RadioSelect方法的典型用法代码示例。如果您正苦于以下问题:Python widgets.RadioSelect方法的具体用法?Python widgets.RadioSelect怎么用?Python widgets.RadioSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms.widgets
的用法示例。
在下文中一共展示了widgets.RadioSelect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: field_display
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import RadioSelect [as 别名]
def field_display(field, safe=False):
out = []
if isinstance(field.field.widget, (forms.widgets.RadioSelect, forms.widgets.CheckboxSelectMultiple)):
out.append('<div class="field radio">%s</div>' % (str(field)))
else:
out.append('<div class="field">%s</div>' % (str(field)))
out.append(str(field.errors))
if field.help_text:
if isinstance(field.help_text, Promise):
out.append('<div class="helptext">%s</div>' % (escape(field.help_text)))
else:
if safe:
out.append('<div class="helptext">%s</div>' % (field.help_text))
else:
out.append('<div class="helptext">%s</div>' % (escape(field.help_text)))
return mark_safe('\n'.join(out))
示例2: label_display
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import RadioSelect [as 别名]
def label_display(field, prefix=''):
out = []
labelid = str(field.name)
if prefix:
labelid = prefix + '-' + labelid
if isinstance(field.field.widget, (RadioSelect, SupervisorWidget)):
labelid += '_0'
out.append('<label for="id_%s">' % (labelid,))
out.append(escape(field.label))
out.append(':')
if field.field.required or (hasattr(field.field, 'force_display_required') and field.field.force_display_required):
out.append(' ' + required_icon)
out.append('</label>')
return mark_safe(''.join(out))
示例3: bootstrap_input_type
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import RadioSelect [as 别名]
def bootstrap_input_type(field):
"""
Return input type to use for field
"""
try:
widget = field.field.widget
except:
raise ValueError("Expected a Field, got a %s" % type(field))
input_type = getattr(widget, 'bootstrap_input_type', None)
if input_type:
return str(input_type)
if isinstance(widget, TextInput):
return u'text'
if isinstance(widget, CheckboxInput):
return u'checkbox'
if isinstance(widget, CheckboxSelectMultiple):
return u'multicheckbox'
if isinstance(widget, RadioSelect):
return u'radioset'
return u'default'