aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
authorTom Christie2013-05-18 17:22:27 +0100
committerTom Christie2013-05-18 17:22:27 +0100
commitbac4bf6e95d6cc6828115bd0a79cd524a6abd163 (patch)
tree431794e91dec87c099ffb3dcce8a50c4ce0507e7 /rest_framework/fields.py
parent0d3d66cb0232e1067600ef22fcf88937ac6bee9d (diff)
parent6af61a19b78b0ebb9d8403e96c6e4a77c675b141 (diff)
downloaddjango-rest-framework-bac4bf6e95d6cc6828115bd0a79cd524a6abd163.tar.bz2
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework
Diffstat (limited to 'rest_framework/fields.py')
-rw-r--r--rest_framework/fields.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index fc14184c..b5f99823 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -26,7 +26,7 @@ from rest_framework import ISO_8601
from rest_framework.compat import timezone, parse_date, parse_datetime, parse_time
from rest_framework.compat import BytesIO
from rest_framework.compat import six
-from rest_framework.compat import smart_text
+from rest_framework.compat import smart_text, force_text, is_non_str_iterable
from rest_framework.settings import api_settings
@@ -45,7 +45,6 @@ def is_simple_callable(obj):
len_defaults = len(defaults) if defaults else 0
return len_args <= len_defaults
-
def get_component(obj, attr_name):
"""
Given an object, and an attribute name,
@@ -169,7 +168,8 @@ class Field(object):
if is_protected_type(value):
return value
- elif hasattr(value, '__iter__') and not isinstance(value, (dict, six.string_types)):
+ elif (is_non_str_iterable(value) and
+ not isinstance(value, (dict, six.string_types))):
return [self.to_native(item) for item in value]
elif isinstance(value, dict):
# Make sure we preserve field ordering, if it exists
@@ -177,7 +177,7 @@ class Field(object):
for key, val in value.items():
ret[key] = self.to_native(val)
return ret
- return smart_text(value)
+ return force_text(value)
def attributes(self):
"""