使用多个需求文件
每个需求文件都应与设置文件的名称匹配。读取使用多个设置以获取更多信息。
结构体
djangoproject
├── config
│ ├── __init__.py
│ ├── requirements
│ │ ├── base.txt
│ │ ├── dev.txt
│ │ ├── test.txt
│ │ └── prod.txt
│ └── settings
└── manage.py
在 base.txt
文件中,放置在所有环境中使用的依赖项。
# base.txt
Django==1.8.0
psycopg2==2.6.1
jinja2==2.8
在所有其他文件中,包含与 -r base.txt
的基本依赖关系,并添加当前环境所需的特定依赖项。
# dev.txt
-r base.txt # includes all dependencies in `base.txt`
# specific dependencies only used in dev env
django-queryinspect==0.1.0
# test.txt
-r base.txt # includes all dependencies in `base.txt`
# specific dependencies only used in test env
nose==1.3.7
django-nose==1.4
# prod.txt
-r base.txt # includes all dependencies in `base.txt`
# specific dependencies only used in production env
django-queryinspect==0.1.0
gunicorn==19.3.0
django-storages-redux==1.3
boto==2.38.0
最后,安装依赖项。例如,关于 dev env:pip install -r config/requirements/dev.txt