mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
Merge with 10e5aa19eecaec9be297dd8f090eb56c60089a6d
This commit is contained in:
commit
5a188d8c90
|
@ -314,7 +314,7 @@ class FormResource(Resource):
|
|||
if not form:
|
||||
return None
|
||||
|
||||
if data is not None:
|
||||
if data is not None or files is not None:
|
||||
return form(data, files)
|
||||
|
||||
return form()
|
||||
|
|
|
@ -12,20 +12,16 @@ class UploadFilesTests(TestCase):
|
|||
|
||||
def test_upload_file(self):
|
||||
|
||||
|
||||
class FileForm(forms.Form):
|
||||
file = forms.FileField
|
||||
|
||||
class MockResource(FormResource):
|
||||
form = FileForm
|
||||
file = forms.FileField()
|
||||
|
||||
class MockView(View):
|
||||
permissions = ()
|
||||
resource = MockResource
|
||||
form = FileForm
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
return {'FILE_NAME': self.CONTENT['file'][0].name,
|
||||
'FILE_CONTENT': self.CONTENT['file'][0].read()}
|
||||
return {'FILE_NAME': self.CONTENT['file'].name,
|
||||
'FILE_CONTENT': self.CONTENT['file'].read()}
|
||||
|
||||
file = StringIO.StringIO('stuff')
|
||||
file.name = 'stuff.txt'
|
||||
|
|
Loading…
Reference in New Issue
Block a user