aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Christie2011-06-30 08:41:51 +0100
committerTom Christie2011-06-30 08:41:51 +0100
commit93e95bac8dd19331a0d1457be09ffcebd966bd03 (patch)
tree9a381c231658e0ba8bb08c9dc74c35da9c1d646f
parente5e019b0b3abc41118a50af7878541b305c2bd5e (diff)
parent019cb7f7d7919739285a8138354c1c8bcda8df1c (diff)
downloaddjango-rest-framework-93e95bac8dd19331a0d1457be09ffcebd966bd03.tar.bz2
merge from astraw
-rw-r--r--djangorestframework/parsers.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/djangorestframework/parsers.py b/djangorestframework/parsers.py
index 3346a26e..37882984 100644
--- a/djangorestframework/parsers.py
+++ b/djangorestframework/parsers.py
@@ -13,6 +13,7 @@ We need a method to be able to:
from django.http import QueryDict
from django.http.multipartparser import MultiPartParser as DjangoMultiPartParser
+from django.http.multipartparser import MultiPartParserError
from django.utils import simplejson as json
from djangorestframework import status
from djangorestframework.response import ErrorResponse
@@ -135,6 +136,10 @@ class MultiPartParser(BaseParser):
`files` will be a :class:`QueryDict` containing all the form files.
"""
upload_handlers = self.view.request._get_upload_handlers()
- django_parser = DjangoMultiPartParser(self.view.request.META, stream, upload_handlers)
+ try:
+ django_parser = DjangoMultiPartParser(self.view.request.META, stream, upload_handlers)
+ except MultiPartParserError, exc:
+ raise ErrorResponse(status.HTTP_400_BAD_REQUEST,
+ {'detail': 'multipart parse error - %s' % unicode(exc)})
return django_parser.parse()