Install system dependencies: sudo apt install libpq-dev python3-venv python3-pip postgresql postgresql-contrib
Create virtual environment: python3 -m venv venv
Activate virtual environment: source venv/bin/activate
Install dependencies: pip install -r requirements.txt
Create a .env
or settings.ini
file with the following:
[settings]
DEBUG=True
PRODUCTION=False
SECRET_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ALLOWED_HOSTS=*
DB_NAME=recipe_box_db
DEBUG
(True or False) sets the Django debug variable. Do not useDEBUG=True
in production.PROUDCTION
determines whether the production static/media content (AWS vs local) is used, and whether to use production database settings.SECRET_KEY
is the Django secret keyAWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
are the credentials for hosting static/media data on AWS S3ALLOWED_HOSTS
is the allowed host for the site to appear on. It shouldn't really be*
(any host).DB_NAME
is the database name in Postgres.
The following parameters are required if you are in a production setting (otherwise, they'll be ignored):
DB_USER=XXXXXXXXXXX
DB_PASSWORD=XXXXXXXXXX
Create/update the database: python manage.py migrate
- If you get the error
role "USERNAME" does not exist
, create the user withsudo -u postgres createuser USERNAME
- If you get the error
database "recipe_box_db" does not exist
, create it:- Run as postgres user:
sudo -i -u postgres
- Create database:
createdb recipe_box_db
- Get out:
exit
- Run as postgres user:
- If you want to copy the existing database from Heroku as a starting place, follow these instructions
Run the server: python manage.py runserver