Here are the instructions to set this API up locally.
If you want to automate below in one step, you can use the included Makefile
. In that case you can just run make setup && make run
and you should be good to go.
To do this setup manually go through these steps:
-
Make a virtual environment:
python -m venv venv
. -
Activate the virtual environment:
source venv/bin/activate
. -
Install the (base) requirements:
pip install -r requirements.txt
. -
Set
SECRET_KEY
andDEBUG
in thevenv/bin/activate
script and run it again so these variables are available. -
Run the migrations:
python manage.py migrate
. -
Create a pybites superuser with password 'changeme':
echo "from django.contrib.auth.models import User; User.objects.create_superuser('pybites', '[email protected]', 'changeme')" | python manage.py shell
-
Import the tips data:
python manage.py sync_tips
. -
Run the webserver:
python manage.py runserver
.
Browse to http://localhost:8000/api/ - enjoy!
This API was initially linked to: Building a Python Tips API with Django REST Framework and Deploying it to Digital Ocean - leaving this here just in case.