Python django.forms 模块,ClearableFileInput() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用django.forms.ClearableFileInput()

项目:wagtailmedia    作者:torchbox    | 项目源码 | 文件源码
def get_media_form(model):
    fields = model.admin_form_fields
    if 'collection' not in fields:
        # force addition of the 'collection' field, because leaving it out can
        # cause dubious results when multiple collections exist (e.g adding the
        # media to the root collection where the user may not have permission) -
        # and when only one collection exists, it will get hidden anyway.
        fields = list(fields) + ['collection']

    return modelform_factory(
        model,
        form=BaseMediaForm,
        fields=fields,
        widgets={
            'tags': widgets.AdminTagWidget,
            'file': forms.FileInput(),
            'thumbnail': forms.ClearableFileInput(),
        })
项目:netbox    作者:digitalocean    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(BootstrapMixin, self).__init__(*args, **kwargs)

        exempt_widgets = [forms.CheckboxInput, forms.ClearableFileInput, forms.FileInput, forms.RadioSelect]

        for field_name, field in self.fields.items():
            if field.widget.__class__ not in exempt_widgets:
                css = field.widget.attrs.get('class', '')
                field.widget.attrs['class'] = ' '.join([css, 'form-control']).strip()
            if field.required and not isinstance(field.widget, forms.FileInput):
                field.widget.attrs['required'] = 'required'
            if 'placeholder' not in field.widget.attrs:
                field.widget.attrs['placeholder'] = field.label
项目:mes    作者:osess    | 项目源码 | 文件源码
def is_file(field):
    return isinstance(field.field.widget, forms.ClearableFileInput)