﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30735	Testing client encode_multipart may also support dict format.	Yannick Chabbert	Yannick Chabbert	"When using implicitly multipart-form data with the testing client (post / put methods), we can't unfortunetly provide data like dict, whereas we could provide file, list and even list of files...
Of course, the actual workaround is to do it manually (cast dict to json) but it should be really great if it could be done automatically!

Furthermore, some third party libraries like Django Rest Framework are limited by this, see https://github.com/encode/django-rest-framework/blob/3.10.2/rest_framework/renderers.py#L907

Concretly with DRF, we would be able to '''test''' file upload '''with''' nested data on an endpoint at the same time. I highlight ''test'' because otherwise in real life, it works if the HTTP client send the dict data as a json string.

Here is just a basic example, with the native Django test client where we '''can't''' do this:
{{{
        with open(filepath, 'rb') as fp:
            response = self.client.post('/post/', data={
                'nested_data': {
                    'firstname': 'foo',
                    'lastname': 'foo',
                },
                'testfile': fp,
            })
}}}

Indeed instead, we have to cast it manually:
{{{
        import json
        with open(filepath, 'rb') as fp:
            response = self.client.post('/post/', data={
                'nested_data': json.dumps({
                    'firstname': 'foo',
                    'lastname': 'foo',
                }),
                'testfile': fp,
            })
}}}
In that case, it would be ok and nested data would be properly parsed.

Finally, the feature request should not be so hard and I have already a working patch. However, I need first to know if it is an acceptable feature request? Am I missing something else?

Thanks for the review"	New feature	closed	Testing framework	dev	Normal	wontfix	test		Unreviewed	1	0	1	0	1	0
