def import_from_string(val, setting_name):
    try:
        parts = val.split('.')
        module_path, class_name = '.'.join(parts[:-1]), parts[-1]
        module = importlib.import_module(module_path)
        return getattr(module, class_name)
    except (ImportError, AttributeError) as e:
        raise ImportError('Could not import {} for API setting {}. {}: {}.'
                          .format(val, setting_name, e.__class__.__name__, e))
Attempt to import a class from a string representation.
dataset/ETHPy150Open ankitpopli1891/django-autotranslate/autotranslate/utils.py/import_from_string