Fixed #29459 -- Initialized form data/files with empty MultiValueDicts.
This commit is contained in:
parent
163236ea0e
commit
4c086d7da4
|
@ -11,6 +11,7 @@ from django.forms.fields import Field, FileField
|
|||
# pretty_name is imported for backwards compatibility in Django 1.9
|
||||
from django.forms.utils import ErrorDict, ErrorList, pretty_name # NOQA
|
||||
from django.forms.widgets import Media, MediaDefiningClass
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.html import conditional_escape, html_safe
|
||||
from django.utils.safestring import mark_safe
|
||||
|
@ -69,8 +70,8 @@ class BaseForm:
|
|||
initial=None, error_class=ErrorList, label_suffix=None,
|
||||
empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None):
|
||||
self.is_bound = data is not None or files is not None
|
||||
self.data = {} if data is None else data
|
||||
self.files = {} if files is None else files
|
||||
self.data = MultiValueDict() if data is None else data
|
||||
self.files = MultiValueDict() if files is None else files
|
||||
self.auto_id = auto_id
|
||||
if prefix is not None:
|
||||
self.prefix = prefix
|
||||
|
|
|
@ -3671,6 +3671,11 @@ Good luck picking a username that doesn't already exist.</p>
|
|||
self.assertTrue(f.is_valid())
|
||||
self.assertEqual(f.cleaned_data, {'data': 'xyzzy'})
|
||||
|
||||
def test_empty_data_files_multi_value_dict(self):
|
||||
p = Person()
|
||||
self.assertIsInstance(p.data, MultiValueDict)
|
||||
self.assertIsInstance(p.files, MultiValueDict)
|
||||
|
||||
|
||||
class CustomRenderer(DjangoTemplates):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue