Django-为settings.py提供更改的路径

时间:2018-06-29 08:32:55

标签: python django configuration

为了简化协作,我像这样更改了现有django项目的目录结构:

├── docs
├── manage.py
├── requirements.txt
├── static
│   └── my_app
│       ├── css
│       ├── fonts
│       ├── img
│       └── js
├── templates
│   └── my_app
└── proj_name
    ├── apps
    │   └── my_app
    │       ⋮
    │       └── views.py
    ├── settings
    │   └── base.py
    ├── urls.py
    └── wsgi.py


部分设置文件base.py

BASE_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '..')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'the actual secret key'

使用manage.py会引发错误

python manage.py makemigrations

django.core.exceptions.AppRegistryNotReady:应用尚未加载。

为了更准确地找出问题,我运行了check,实际上它引发了另一个错误

python manage.py check

django.core.exceptions.ImproperlyConfigured:SECRET_KEY设置不能为空。
在更改目录结构之前,项目已经开始工作。

如何更改django-project settings-file的路径?


目录重组受启发 Best practice for Django project working directory structure

0 个答案:

没有答案
相关问题