aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/compat.py
diff options
context:
space:
mode:
authorTom Christie2014-12-16 16:37:32 +0000
committerTom Christie2014-12-16 16:37:32 +0000
commitfe9647ce92b61b57dc64604241352bf269d65af7 (patch)
tree297433613ec00ef59a02ce932fd8a75ef9ca223f /rest_framework/compat.py
parent4e91ec61339838426e246e20ef062c963a78c4e1 (diff)
downloaddjango-rest-framework-fe9647ce92b61b57dc64604241352bf269d65af7.tar.bz2
AcceptHeaderVersioning to return unicode strings.
Diffstat (limited to 'rest_framework/compat.py')
-rw-r--r--rest_framework/compat.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py
index c5242343..3c8fb0da 100644
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -5,15 +5,13 @@ versions of django/python, and compatibility wrappers around optional packages.
# flake8: noqa
from __future__ import unicode_literals
-
-import inspect
-
from django.core.exceptions import ImproperlyConfigured
+from django.conf import settings
from django.utils.encoding import force_text
from django.utils.six.moves.urllib import parse as urlparse
-from django.conf import settings
from django.utils import six
import django
+import inspect
def unicode_repr(instance):
@@ -33,6 +31,13 @@ def unicode_to_repr(value):
return value
+def unicode_http_header(value):
+ # Coerce HTTP header value to unicode.
+ if isinstance(value, six.binary_type):
+ return value.decode('iso-8859-1')
+ return value
+
+
# OrderedDict only available in Python 2.7.
# This will always be the case in Django 1.7 and above, as these versions
# no longer support Python 2.6.