mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Handle AttributeError as well (when the imported module exists but
the specified function/class does not).
This commit is contained in:
parent
5833a1847f
commit
f0bced6413
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user