- A series of activities provided to learn Django as a whole and as a backend
- Virtual Environment
- Use virtualenv to add a virtual environment
virtualenv venv
- Activate the environment
source venv/bin/activate #Ubuntu
- Deactivate enviroment
deactivate
- Remove environment
rm -rf venv
Check this info for windows
- Install requirements for python3
- (Optional) Upgrade Tools
pip3 install --upgrade setuptools #pip only for Windows
- (Optional) Upgrade Pip
python3 -m pip install --upgrade pip #python only for Windows unless there is other version
- Install requirements in requirements.txt
pip3 install -r requirements.txt
- Environment Variables
- In source folder aligned with manage.py create .env file
plmat-drf\
... # other files
.env
manage.py
- Create variables inside env file
- For development, copy the variables inside the development.env to .env
- For production, copy the variables inside the production.env to .env
- Setup Postgresql
- Follow the installation on this guide
- By default
server: localhost
database: postgres
port: 5432
username: postgres
password: <your password entered via installation>
- Those keys will be used via .env DATABASE_URL, replace:
DATABASE_URL = "postgresql://<yourusername>:<yourpassword>@<yourhost>:<yourport>/<yourdatabase>"
e.g DATABASE_URL = "postgresql://root:123@root:5432/test"
- Common Commands for Django
- Makemigrations
python3 manage.py makemigrations
- Migrate Applications
python3 manage.py migrate
- Run server for Django
python3 manage.py runserver (port) # default is 8000