
上QQ阅读APP看书,第一时间看更新
How to do it...
Execute the following steps one by one to prepare pip requirements for your virtual environment Django project:
- Let's go to the Django project that you have under version control and create a requirements directory with the following text files:
- _base.txt for shared modules
- dev.txt for the development environment
- test.txt for the testing environment
- staging.txt for the staging environment
- production.txt for production
- Edit _base.txt and add the Python modules that are shared in all environments, line by line:
# requirements/_base.txt
Django~=3.0.4
djangorestframework
-e git://github.com/omab/python-social-auth.git@6b1e301c79#egg=python-social-auth
If the requirements of a specific environment are the same as in _base.txt, add the line including _base.txt in the requirements file of that environment, as shown in the following example:
# requirements/production.txt
-r _base.txt
- If there are specific requirements for an environment, add them after the _base.txt inclusion, as shown in the following code:
# requirements/dev.txt
-r _base.txt
coverage
django-debug-toolbar
selenium
You can run the following command in a virtual environment in order to install all of the required dependencies for the development environment (or an analogous command for other environments), as follows:
(env)$ pip install -r requirements/dev.txt