我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用django.forms.forms.BaseForm()。
def patch(): from django.forms import forms, formsets, util, widgets # Add __html__ methods to these classes: classes = [ forms.BaseForm, forms.BoundField, formsets.BaseFormSet, util.ErrorDict, util.ErrorList, widgets.Media, widgets.RadioFieldRenderer, ] try: classes.append(widgets.RadioChoiceInput) except AttributeError: classes.append(widgets.RadioInput) for cls in classes: if not hasattr(cls, '__html__'): cls.__html__ = __html__
def __init__(self, form, *args, **kwargs): if not isinstance(form, BaseForm): raise BootstrapError( 'Parameter "form" should contain a valid Django Form.') self.form = form super(FormRenderer, self).__init__(*args, **kwargs) self.error_css_class = kwargs.get('error_css_class', None) self.required_css_class = kwargs.get('required_css_class', None) self.bound_css_class = kwargs.get('bound_css_class', None)
def __init__(self, form, *args, **kwargs): if not isinstance(form, BaseForm): raise BootstrapError( 'Parameter "form" should contain a valid Django Form.') self.form = form super(FormRenderer, self).__init__(*args, **kwargs) # Handle form.empty_permitted if self.form.empty_permitted: self.set_required = False self.error_css_class = kwargs.get('error_css_class', None) self.required_css_class = kwargs.get('required_css_class', None) self.bound_css_class = kwargs.get('bound_css_class', None)
def __init__(self, form, *args, **kwargs): if not isinstance(form, BaseForm): raise PropellerError( 'Parameter "form" should contain a valid Django Form.') self.form = form super(FormRenderer, self).__init__(*args, **kwargs) # Handle form.empty_permitted if PROPELLER_SET_REQUIRED_SET_DISABLED and self.form.empty_permitted: self.set_required = False self.error_css_class = kwargs.get('error_css_class', None) self.required_css_class = kwargs.get('required_css_class', None) self.bound_css_class = kwargs.get('bound_css_class', None)