Don't convert to POST vars if POST is already populated.

Otherwise you could encounter errors if you POST to a method
with this decorator applied.

(imported from commit bcb31f336ea2a1eeee6b9e3e9dfeed1d205ae26a)
This commit is contained in:
Luke Faraone 2013-04-03 13:01:58 -07:00
parent 50809ca219
commit 3fd2bfa19e

View File

@ -124,11 +124,14 @@ def process_as_post(view_func):
#
# This will not be required in the future, a bug will be filed against
# Django upstream.
if request.META.get('CONTENT_TYPE', '').startswith('multipart'):
request.POST = MultiPartParser(request.META, StringIO(request.body),
[], request.encoding).parse()[0]
else:
request.POST = QueryDict(request.body, encoding=request.encoding)
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]
else:
request.POST = QueryDict(request.body, encoding=request.encoding)
return view_func(request, *args, **kwargs)