我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用django.forms.widgets.RadioSelect()。
def __init__(self, label_class='radio inline', *args, **kwargs): super(RadioSelect, self).__init__(*args, **kwargs) self.label_class = label_class
def get_form(self, request, obj=None, **kwargs): form = super(ContentAdmin, self).get_form(request, obj, **kwargs) form.base_fields['identifier'].widget = RadioSelect(choices=CONTENT_IDENTIFIERS) return form
def get_form(self, request, obj=None, **kwargs): form = super(ImageAdmin, self).get_form(request, obj, **kwargs) form.base_fields['identifier'].widget = RadioSelect(choices=IMAGE_IDENTIFIERS) return form
def is_radio(value): if not isinstance(value, BoundField): return False return isinstance(value.field.widget, RadioSelect)