Commit c7046df0 by Don Mitchell

Make request.POST be only json content when using expect_json

parent 115b214d
...@@ -15,8 +15,7 @@ def expect_json(view_function): ...@@ -15,8 +15,7 @@ def expect_json(view_function):
# e.g. 'charset', so we can't do a direct string compare # e.g. 'charset', so we can't do a direct string compare
if request.META.get('CONTENT_TYPE', '').lower().startswith("application/json"): if request.META.get('CONTENT_TYPE', '').lower().startswith("application/json"):
cloned_request = copy.copy(request) cloned_request = copy.copy(request)
cloned_request.POST = cloned_request.POST.copy() cloned_request.POST = json.loads(request.body)
cloned_request.POST.update(json.loads(request.body))
return view_function(cloned_request, *args, **kwargs) return view_function(cloned_request, *args, **kwargs)
else: else:
return view_function(request, *args, **kwargs) return view_function(request, *args, **kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment