This repository contains a django web project that provides a simple way to coordinate food delivery orders.
A coordinator can announce a food delivery order and then tell other people to add food requests. When the coordinator decides to place the order, food requests are frozen and can't be changed anymore. Finally, people pay, food is delivered, everyone is happy.
Software required:
To setup the development environment:
make build-image
make start-db
Run linters:
$ make lint
Run tests:
$ make test
Pass additional parameters to pytest, e.g. to only run model tests:
$ TESTOPS='-k test_models' make test
Run a shell using the build image (access manage.py
, etc):
$ make dev-shell
When using the django test client, make sure to run the following lines first:
import django
django.test.utils.setup_test_environment()
Create database schema:
$ make migrate
Run the django development server:
$ make run
The application is available at http://localhost:8000
.
Django admin:
http://localhost:8000/admin/
http://localhost:8000/admin/doc/
The admin user must be created via python manage.py createsuperuser
.
Requirements are managed via pipenv
.
The django application requires a set of environment variables to be
configured. For development, only DJANGO_DATABASE_URL
is required and can be
configured by e.g. direnv.
DJANGO_DATABASE_URL
:
URL to database.
Format: postgresql://[username]:[password]@[hostname]:5432/[dbname]
dj-environ explains this in detail.
The project provides a docker container to runs the django application in gunicorn. For production, the following parameters must be configured:
DJANGO_SECRET_KEY
:
Secret key for cryptographic signing.
DJANGO_ALLOWED_HOSTS
:
Public http hostname of the site.
Optional parameters:
DJANGO_STATIC_ROOT
:
Default value: [projectroot]/staticfiles
Local directory where static files are stored for serving.
DJANGO_STATIC_URL
:
Default value: /static/
URL prefix where static files are served.
DJANGO_ADMIN_EMAIL
:
Default value: admin@example.org
DJANGO_ADMIN_USERNAME
:
Default value: admin
DJANGO_ADMIN_PASSWORD
:
Default value: admin
GUNICORN_BIND_PORT
:
Default value: 8000
GUNICORN_WORKERS
:
Default value: 4
SENTRY_DSN
:
The production environment includes sentry error reporting, this must be set to the DSN as shown by sentry when creating a new project.