From 2b28cf9a0a56a2a9de7abef48d23a6dc9353dda9 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 1 Aug 2013 13:33:30 -0400 Subject: [PATCH] Support request.FILES in process_as_post. (imported from commit 646019b5efe4ae3f6f66f99f76f2036d9fd9ec8e) --- zephyr/decorator.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zephyr/decorator.py b/zephyr/decorator.py index cbc1ccf003..8416be5ae0 100644 --- a/zephyr/decorator.py +++ b/zephyr/decorator.py @@ -141,8 +141,11 @@ def process_as_post(view_func): if not request.POST: # Only take action if POST is empty. if request.META.get('CONTENT_TYPE', '').startswith('multipart'): - request.POST = MultiPartParser(request.META, StringIO(request.body), - [], request.encoding).parse()[0] + # Note that request._files is just the private attribute that backs the + # FILES property, so we are essentially setting request.FILES here. (In + # Django 1.5 FILES was still a read-only property.) + request.POST, request._files = MultiPartParser(request.META, StringIO(request.body), + request.upload_handlers, request.encoding).parse() else: request.POST = QueryDict(request.body, encoding=request.encoding)