From f0bced64134b10c2cafbb206c04fe0fa774d205d Mon Sep 17 00:00:00 2001 From: Laszlo Marai Date: Tue, 30 Jun 2015 05:49:44 +0200 Subject: [PATCH] Handle AttributeError as well (when the imported module exists but the specified function/class does not). --- rest_framework/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/settings.py b/rest_framework/settings.py index 4c46a4831..a7b63721e 100644 --- a/rest_framework/settings.py +++ b/rest_framework/settings.py @@ -171,7 +171,7 @@ def import_from_string(val, setting_name): module_path, class_name = '.'.join(parts[:-1]), parts[-1] module = importlib.import_module(module_path) return getattr(module, class_name) - except ImportError as e: + except (ImportError, AttributeError) as e: msg = "Could not import '%s' for API setting '%s'. %s: %s." % (val, setting_name, e.__class__.__name__, e) raise ImportError(msg)