mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Merge pull request #3088 from atleta/master
Handle AttributeError as well (when the imported module exists but the specified function/class does not).
This commit is contained in:
commit
39ed03c21c
|
@ -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