Django Using multiple requirements files


Example

Each requirements files should match the name of a settings files. Read Using multiple settings for more information.

Structure

djangoproject
├── config
│   ├── __init__.py
│   ├── requirements
│   │   ├── base.txt
│   │   ├── dev.txt
│   │   ├── test.txt
│   │   └── prod.txt
│   └── settings
└── manage.py

In base.txt file, place dependencies used in all environments.

# base.txt
Django==1.8.0
psycopg2==2.6.1
jinja2==2.8

And in all other files, include base dependencies with -r base.txt, and add specific dependencies needed for the current environment.

# 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

Finally, to install dependencies. Example, on dev env : pip install -r config/requirements/dev.txt