为了简化协作,我像这样更改了现有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_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'
python manage.py makemigrations
django.core.exceptions.AppRegistryNotReady:应用尚未加载。
为了更准确地找出问题,我运行了check
,实际上它引发了另一个错误
python manage.py check
django.core.exceptions.ImproperlyConfigured:SECRET_KEY设置不能为空。
在更改目录结构之前,项目已经开始工作。
目录重组受启发 Best practice for Django project working directory structure