diff options
| author | Tom Christie | 2013-06-05 13:33:19 +0100 |
|---|---|---|
| committer | Tom Christie | 2013-06-05 13:33:19 +0100 |
| commit | de00ec95c3007dd90b5b01f7486b430699ea63c1 (patch) | |
| tree | d2ce8037d446fd9133b3d6a77ebcc49350d7ebc3 /rest_framework/compat.py | |
| parent | 9428d6ddb5ebc2d5d9c8557a52be09f0def69cca (diff) | |
| parent | 2ca243a1144bb2a5461767a21ed14dec1d2b8dc2 (diff) | |
| download | django-rest-framework-de00ec95c3007dd90b5b01f7486b430699ea63c1.tar.bz2 | |
Merge master
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 13 |
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__') |
