django.py 文件源码

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

项目:python-boilerplate 作者: fabiommendes 项目源码 文件源码
def project_root():
    """
    Return the project root.
    """

    try:
        return get_option('django', 'project_root')
    except ValueError:
        pass

    # No configuration was found. We need to search for a django project in the
    # package tree. The first option is that the project adopts the
    # python-boilerplate layout for a django project:
    pyname = get_option('options', 'pyname')
    if os.path.exists(os.path.join('src', pyname, 'site')):
        return pyname + '.site'

    # Secondly, it might be a layout for a django app. In this case, the
    # project root points to the test project inside the "tests" folder
    if os.path.exists(os.path.join('src', pyname, 'tests', 'site')):
        return pyname + '.tests.site'

    # Everything fails! Quit!
    raise RuntimeError(
        'Could not determine the project root. Is this a really django '
        'project? Please run `python-boilerplate django-project` or '
        '`python-boilerplate django-app` in order to create a project '
        'structure.'
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号