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.'
)
评论列表
文章目录