This is a base project for API applications built with Django and Django Rest Framework.
Includes several customizations on top of Django Rest Framework for JWT authentication, normalized responses and global exception handling.
Built with Django 2.1.7 and Django Rest Framework 3.9.2 . Tested with Python 3.6
Api expects database settings to be defined in environment variables, to be able to run the server and tests. Required environment variables are:
dbname: Name of the database
dbuser: Name of the database user
dbpass: Password for database user
dbhost: Hostname of the database server
dbport: Port on which the database server is listening
Run python manage.py runserver
for a dev server. Navigate to http://localhost:8000/
.
Run python manage.py test
to execute the unit tests.
Project is bundled with a simple setup for deployment via Docker. After cd-ing into the project directory, run the following commands to build a docker image and run it:
docker image build -t django-api-base .
docker run -d -p host_port:80 -e dbname=database_name -e dbuser=database_user -e dbpass=database_password -e dbhost=database_host -e dbport=database_port django-api-base