aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/compat.py
diff options
context:
space:
mode:
authorTom Christie2013-05-18 09:05:42 -0700
committerTom Christie2013-05-18 09:05:42 -0700
commit1888f4a1f01c03384fd401ee90002d1cda955425 (patch)
tree544f96cbee9d1e31fe70e02e42fadbc5e8055056 /rest_framework/compat.py
parent6d5cf527c32402436b8300324715779c41f50fd7 (diff)
parent579f77ceaa03a216a7a635c3d3a4d83b0e5868f8 (diff)
downloaddjango-rest-framework-1888f4a1f01c03384fd401ee90002d1cda955425.tar.bz2
Merge pull request #865 from ryankask/issue-747-lazy-strings-serialized
Issue 747 lazy strings serialized
Diffstat (limited to 'rest_framework/compat.py')
-rw-r--r--rest_framework/compat.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py
index cd39f544..76dc0052 100644
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -495,3 +495,16 @@ except ImportError:
oauth2_provider_forms = None
oauth2_provider_scope = None
oauth2_constants = None
+
+# Handle lazy strings
+from django.utils.functional import Promise
+
+if six.PY3:
+ def is_non_str_iterable(obj):
+ if (isinstance(obj, str) or
+ (isinstance(obj, Promise) and obj._delegate_text)):
+ return False
+ return hasattr(obj, '__iter__')
+else:
+ def is_non_str_iterable(obj):
+ return hasattr(obj, '__iter__')