diff options
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py index efd2581f..b4d37ab8 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -65,6 +65,13 @@ try: except ImportError: import urlparse +# UserDict moves in Python 3 +try: + from UserDict import UserDict + from UserDict import DictMixin +except ImportError: + from collections import UserDict + from collections import MutableMapping as DictMixin # Try to import PIL in either of the two ways it can end up installed. try: @@ -76,6 +83,22 @@ except ImportError: Image = None +def get_model_name(model_cls): + try: + return model_cls._meta.model_name + except AttributeError: + # < 1.6 used module_name instead of model_name + return model_cls._meta.module_name + + +def get_concrete_model(model_cls): + try: + return model_cls._meta.concrete_model + except AttributeError: + # 1.3 does not include concrete model + return model_cls + + # Django 1.5 add support for custom auth user model if django.VERSION >= (1, 5): AUTH_USER_MODEL = settings.AUTH_USER_MODEL |
