This project is a guide to REST API development with the help of Django Rest Framework.
A Test Driven Development approach is used to build out this project and API contains features such as,
- Fully fledged Authentication mechanisam
- Image Upload
- CRUD and relations
and much more.
Getting started with the TDD-With-Django-REST
is easy.
- First clone the project.
git clone https://github.com/DevDHera/TDD-With-Django-REST.git
-
Start your docker machine.
-
Go to the root of your cloned project and build the docker image.
docker-compose build
- Do the neccessary migrations.
docker-compose run --rm app sh -c "python manage.py makemigrations"
- Run the app using
docker-compose
.
docker-compose up
- Now head over to our issue board and help solving issues πΌ.
TDD-With-Django-REST
uses Docker to manage containers.
In order to successfully run the project install the following.
- Docker
After installing the above you can provision services as you like using the docker-compose.yml
file on the root of the project.
Following is the structure that we are using.
version: '3'
services:
app:
restart: always
build:
context: .
ports:
- '8000:8000'
volumes:
- ./app:/app
command: >
sh -c "python manage.py wait_for_db &&
python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db
- DB_NAME=app
- DB_USER=postgres
- DB_PASS=supersecretpassword
depends_on:
- db
db:
image: postgres:12-alpine
environment:
- POSTGRES_DB=app
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=supersecretpassword
As the project uses a TDD approach test take a key role. Following describes how you can run the tests and lints.
Each app contains test folder that will is used to test each part of the API. You can run these tests by using the below script.
docker-compose run --rm app sh -c "python manage.py test"
Flake8 is used to enforce the coding styles. Lint command as belows.
docker-compose run --rm app sh -c "flake8"
You can run both the tests and lints in one go like below.
docker-compose run --rm app sh -c "python manage.py test && flake8"
To deploy the API first you can use the power of docker-compose
.
Simply run the belwo.
docker-compose up
- Django - The web framework used
- Django Rest Framework - Web API Framework
- PostgreSQL - DB Used
- psycopg2 - PostgreSQL database adapter
- flake8 - Linter
- Docker - Container Manager
Please read CODE_OF_CONDUCT.md for details on our code of conduct, and the process for submitting pull requests to us.
- Devin Herath - Initial work - DevDHera
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.
- PurpleBooth for this awesome README template β€οΈ