Ticket #5387: form-is-multipart.diff

File form-is-multipart.diff, 1.2 KB (added by Petr Marhoun <petr.marhoun@…>, 8 years ago)
  • django/newforms/forms.py

    === modified file 'django/newforms/forms.py'
     
    210210        """
    211211        return self.cleaned_data
    212212
     213    def is_multipart(self):
     214        for field in self.fields.values():
     215            if field.widget.needs_multipart_form:
     216                return True
     217        return False
     218
    213219class Form(BaseForm):
    214220    "A collection of Fields, plus their associated data."
    215221    # This is a separate class from BaseForm in order to abstract the way
  • django/newforms/widgets.py

    === modified file 'django/newforms/widgets.py'
     
    2424
    2525class Widget(object):
    2626    is_hidden = False          # Determines whether this corresponds to an <input type="hidden">.
     27    needs_multipart_form = False
    2728
    2829    def __init__(self, attrs=None):
    2930        if attrs is not None:
     
    120121
    121122class FileInput(Input):
    122123    input_type = 'file'
     124    needs_multipart_form = True
    123125
    124126    def render(self, name, value, attrs=None):
    125127        return super(FileInput, self).render(name, None, attrs=attrs)
Back to Top