using rsplit to get module and classname for imports (#5712)

This commit is contained in:
David De Sousa 2018-01-02 10:59:08 +01:00 committed by Carlton Gibson
parent 0712094ea2
commit 6b0bf72bb8

View File

@ -179,8 +179,7 @@ def import_from_string(val, setting_name):
"""
try:
# Nod to tastypie's use of importlib.
parts = val.split('.')
module_path, class_name = '.'.join(parts[:-1]), parts[-1]
module_path, class_name = val.rsplit('.', 1)
module = import_module(module_path)
return getattr(module, class_name)
except (ImportError, AttributeError) as e: