Simple django app for use in the docker-local-dev blog post.
Related repositories:
- public-docker-local-dev is the main repository for the local dev environment
- https://github.com/vidahealth/public-example-django (this respository) is the example main backend webserver service
- public-example-microservice is an example of a "microservice" that makes calls back to the main backend web service
pyenv virtualenv 3.9.7 example-django
pip install -r requirements.txt
django-admin startproject tutorial
cd tutorial
./manage.py startapp quickstart
Followed DRF quickstart https://www.django-rest-framework.org/tutorial/quickstart/
when deployed with PyCharm
curl localhost:8000/status
We use the postgres admin account for simplicity, so we do not need to create users or give permissions.
# migrate the database
./manage.py migrate
python manage.py createsuperuser
Username: admin
Email address: [email protected]
Password: password
If we did not use the postgres admin user, we would need to create a new user If we did, that might look like the following from local dev postgres (docker exec)
createuser --pwprompt mydatabaseuser
createdb mydatabase -O mydatabaseuser
# enable the test user to create test databases
psql -c "alter user mydatabaseuser createdb" -d mydatabase
if you forgot to set the password of the database user
psql -c "ALTER ROLE mydatabaseuser WITH PASSWORD 'mypassword'"