aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
authorNikolaus Schlemm2013-05-19 09:02:07 +0200
committerNikolaus Schlemm2013-05-19 09:02:07 +0200
commit9454e23aa927931dcb7a6921c6ad238f6369e64e (patch)
tree967fcbf13b3186a187c72ca9645cb24dbf6b425a /rest_framework/fields.py
parent843ae6023753a0373eb2e6398ddda93e4da74de5 (diff)
parent7c945b43f05f1b340f78c23f80c8043937c7fd2a (diff)
downloaddjango-rest-framework-9454e23aa927931dcb7a6921c6ad238f6369e64e.tar.bz2
Merge branch 'master' of git://github.com/tomchristie/django-rest-framework into issue-192-expose-fields-for-options
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 0f07aaba..d6db3ebe 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -27,7 +27,7 @@ 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
@@ -76,7 +76,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,
@@ -256,7 +255,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
@@ -264,7 +264,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):
"""