From 3d35b2939c4fde0115e20250b54920d5bec962e7 Mon Sep 17 00:00:00 2001 From: Uros Trebec Date: Mon, 30 Sep 2013 23:09:26 +0200 Subject: [PATCH] Fixed UnicodeEncodeError when POST request's parameters include an Unicode character After getting lots of "'latin-1' codec can't encode characters in position 62-66: ordinal not in range(256)" when POSTing valid Unicode characters with "multipart/form-data" requests I figured out that the issue is that '_perform_form_overloading()' is trying to encode the form data as with 'iso-8859-1' which fails. --- rest_framework/request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/request.py b/rest_framework/request.py index 977d4d965..addafaf78 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -334,7 +334,7 @@ class Request(object): self._CONTENT_PARAM in self._data and self._CONTENTTYPE_PARAM in self._data): self._content_type = self._data[self._CONTENTTYPE_PARAM] - self._stream = BytesIO(self._data[self._CONTENT_PARAM].encode(HTTP_HEADER_ENCODING)) + self._stream = BytesIO(self._data[self._CONTENT_PARAM].encode('utf-8')) self._data, self._files = (Empty, Empty) def _parse(self):