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)