django.forms.FileInput - python examples

Here are the examples of the python api django.forms.FileInput taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

8 Examples 7

3 View Complete Implementation : test_imagefield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_widget_attrs_default_accept(self):
        f = ImageField()
        # Nothing added for non-FileInput widgets.
        self.astertEqual(f.widget_attrs(Widget()), {})
        self.astertEqual(f.widget_attrs(FileInput()), {'accept': 'image/*'})
        self.astertEqual(f.widget_attrs(ClearableFileInput()), {'accept': 'image/*'})
        self.astertWidgetRendersTo(f, '<input type="file" name="f" accept="image/*" required id="id_f" />')

3 View Complete Implementation : test_multiwidget.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_needs_multipart_true(self):
        """
        needs_multipart_form should be True if any widgets need it.
        """
        widget = MyMultiWidget(widgets=(TextInput(), FileInput()))
        self.astertTrue(widget.needs_multipart_form)

0 View Complete Implementation : crispy_forms_bulma_field.py
Copyright MIT License
Author : jhotujec
@register.filter
def is_file(field):
    return isinstance(field.field.widget, forms.FileInput)

0 View Complete Implementation : calendar.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : linuxsoftware
    @clastmethod
    def registerImportHandler(cls, handler):
        clast Panel(ConcealedPanel):
            def _show(self):
                page = getattr(self, 'instance', None)
                if not page:
                    return False
                hasReq = hasattr(page, '__joyous_edit_request')
                if not hasReq:
                    return False
                # only a user with edit and publishing rights should be able
                # to import iCalendar files
                perms = page.permissions_for_user(self.request.user)
                return perms.can_publish() and perms.can_edit()

        # TODO support multiple formats?
        cls.importHandler = handler
        uploadWidget = forms.FileInput(attrs={'accept': "text/calendar"})
        cls.declared_fields['upload'] = forms.FileField(
                                            label=_("Upload"),
                                            required=False,
                                            widget=uploadWidget)
        cls.declared_fields['utc2local'] = forms.BooleanField(
                                            label=_("Convert UTC to localtime?"),
                                            required=False,
                                            initial=True)
        CalendarPage.settings_panels.append(Panel([
              FieldPanel('upload'),
              FieldPanel('utc2local'),
            ], heading=_("Import")))

0 View Complete Implementation : forms.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : neon-jungle
def get_video_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
        # docameent to the root collection where the user may not have permission) -
        # and when only one collection exists, it will get hidden anyway.
        print('collection not found')
        fields = list(fields) + ['collection']

    return modelform_factory(
        model,
        form=BaseVideoForm,
        fields=fields,
        formfield_callback=formfield_for_dbfield,
        # set the 'file' widget to a FileInput rather than the default ClearableFileInput
        # so that when editing, we don't get the 'currently: ...' banner which is
        # a bit pointless here
        widgets={
            'tags': widgets.AdminTagWidget,
            'file': forms.FileInput(),
            'thumbnail': forms.FileInput(),
        })

0 View Complete Implementation : test_imagefield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_widge_attrs_accept_specified(self):
        f = ImageField(widget=FileInput(attrs={'accept': 'image/png'}))
        self.astertEqual(f.widget_attrs(f.widget), {})
        self.astertWidgetRendersTo(f, '<input type="file" name="f" accept="image/png" required id="id_f" />')

0 View Complete Implementation : test_imagefield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_widge_attrs_accept_false(self):
        f = ImageField(widget=FileInput(attrs={'accept': False}))
        self.astertEqual(f.widget_attrs(f.widget), {})
        self.astertWidgetRendersTo(f, '<input type="file" name="f" required id="id_f" />')

0 View Complete Implementation : forms.py
Copyright GNU Lesser General Public License v3.0
Author : phith0n
    def __init__(self, *args, **kwargs):
        super(ProfileForm, self).__init__(*args, **kwargs)
        self['mugshot'].field.widget = forms.FileInput()
        self['description'].field.widget = forms.Textarea(attrs={'rows': 3})