A simple website for family recipes, made with django.
- System-wide:
docker
,docker-compose
,python3
,django
- Python: See requirements.txt
- Create file
.env
, hidden from version control, which sets the variablesPOSTGRES_USER
,POSTGRES_PASSWORD
,POSTGRESS_DB
, andSECRET_KEY
- Run the docker container:
sudo docker-compose up
. - Create python virtual environment:
python -m venv env
- Enter python virtual environment:
source env/bin/activate
- Install required python packages:
pip install -r requirements.txt
- Make initial migrations:
python manage.py migrate
- Create an admin user for the local database:
python manage.py createsuperuser
- Start the development server:
python manage.py runserver --settings base.settings.dev
- Start the vite development server for js componenents: From the "frontend" directory, run
npm run dev
- Preview site in browser at localhost:8000
- Change models (models.py)
- Run
python manage.py makemigrations
to create migrations for those changes - Run
python manage.py migrate
to apply those changes to the database.
- In a development environment, push changes to the dev branch. To push frontend changes, run
npm run build
and then push the automatically generated changes. - On the production server, check out the dev branch (
git checkout dev
) and pull the latest changes (git pull
). - Enter python virtual environment:
source env/bin/activate
- Run the production server:
python3 manage.py runserver --settings base.settings.production
- Collect static files (so that nginx will manage them):
python3 manage.py collectstatic --settings base.settings.production
- If models have changed, apply migrations:
python3 manage.py migrate --settings base.settings.production
- If everything looks good, check out the main branch on the production server (
git checkout main
) and merge changes from dev (git merge dev
).