diff options
| author | Ryan Kaskel | 2013-05-18 17:04:17 +0100 | 
|---|---|---|
| committer | Ryan Kaskel | 2013-05-18 17:04:17 +0100 | 
| commit | 579f77ceaa03a216a7a635c3d3a4d83b0e5868f8 (patch) | |
| tree | bd17f41e24540b6e3eb1c088e54024a491ccaebe /rest_framework/compat.py | |
| parent | 33f702d306093126b9b033bb2be0cf9391629c6b (diff) | |
| download | django-rest-framework-579f77ceaa03a216a7a635c3d3a4d83b0e5868f8.tar.bz2 | |
Move function to compat.
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__') | 
