pip install virtualenv
(I always like to called the virtual environment as venv)
virtualenv venv
cd venv
scripts\activate
source bin\activate
cd ..
cd backend
cd src
pip install -r requirements-dev.txt
pip install -r requirements-prod.txt
A management custom command added to rename project name and all the related places where changes must be done to run the project.
python manage.py rename project_name
For security purpose this boilerplate's backend uses python-decouple to secure all sensitive variables like SECRECT_KEY, Production level database username, password etc to a secure file called .env
For local development you can rename the .env.example file to .env to run the project on local computer.
cd frontend
npm install
npm run build
cd backend/src
python manage.py collectstatic
python manage.py runserver
There are two instruction file(project folder) on how to deploy django projects on heroku and digital ocean (I am continuously updating these to file) and more like AWS and others will be added in the future.
Django suggest if any custom command has to create for a project it should be on the core > management > command folder. Like I created the rename command
src > mysite > settings There are three file
- base.py
- developement.py
- production.py
base.py file has contain things that both needed for both development and production settings.
Development settings included Django debug tools and which is helpful for debugging a Django project.
Production settings I configured Database to use PostgreSQL so to secure the database sensitive information like DB_NAME, DB_USER, DB_PASSWORD etc I use the python-decouple module.
By default python-decouple check for .env file for sensitive information of the project.
This .env file should not be push on the public repository. You can create variable on the hosting site so just created their will auto fetch value by python-decouple module.
Checkout the .env.example file to create a .env file
Note .env.example file contain the Django project SECRET_KEY and it's just a 50 character long random number so you change it when you use this boilerplate.
If anyone want to change the project to use the production settings just change one place only.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings.development') to os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings.production')