views.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:django-chartwerk 作者: DallasMorningNews 项目源码 文件源码
def import_class(val):
    """Attempt to import a class from a string representation.

    Pattern borrowed from Django REST Framework.
    See rest_framework/settings.py#L170-L182
    """
    try:
        parts = val.split('.')
        module_path, class_name = '.'.join(parts[:-1]), parts[-1]
        module = import_module(module_path)
        return getattr(module, class_name)
    except (ImportError, AttributeError) as e:
        msg = "Could not import auth/permission class '{}'. {}: {}.".format(
            val,
            e.__class__.__name__,
            e)
        raise ImportError(msg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号