Skip to content

This is a tutorial to build for workflow API using django

Notifications You must be signed in to change notification settings

abhikghosh12/workflowapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 

Repository files navigation

How to use the workflow API

Within this short documentation, we want to show how to use the workflow api. This readme describes every step required to get going with your own object detection classifier:

  1. Requirements
  2. Build the API
  3. Unit tests
  4. Update databases
  5. API Endpoints
  6. Testing the API (Integration tests)
  7. Known problems with solutions

Requirements

  • Django==2.2.3
  • Python==3.7.7
  • djangorestframework==3.10.2
  • drf-nested-routers

Install

pip install -r requirements.txt

Overview

It uses django rest framework to build API. Here lets Build, run and test the app. It creats a nested serializer and uses HTTP REST methods to do all CRUD functions.

The figure shows the Overview of the project. This has app folder called workflowapp and project folder workflowapi.

retrieve from workflow api

Build the API

This will built the django API with sqlite3 databases.

python manage.py migrate
python manage.py makemigrations workflowapp

Unit tests

This unit test test_comment.py and test_workflow.py checks:

  • Create a workflow with API.
  • GET a workflow with API.
  • Update a workflow with API.
  • Delete a workflow with API.
  • Get workflow list.
  • Create a comment with API.
  • GET a comment with API.
  • Update a comment with API.
  • Delete a comment with API.
  • Get comment list.
    python manage.py test

Update databases :

This Update update_db.py checks the model and serializers. This populates the databases with initial data. Here JSON data are provided for workflow and comment.

python update.py

Note: If error comes refer Known problems with solutions Known problems with solutions

Start the Server:

This will start the localserver at : http://localhost:8000/

python manage.py runserver

Create superuser:

or

Create a new superuser

python manage.py createsuperuser

API Endpoints

workflow

comment

  • /comment/: comment-list(Todo create and list endpoint)
  • /comment/{pk}/: comment-detail(Todo retrieve, update and destroy endpoint)

Testing the API (Integration tests)

API is tested using Insomnia for CRUD function. It is tested on workflow and comment api end points.

Make a GET Request

Let's make another post request, to create some data. Make a New Request and select the proper type & format. Then, complete the request URL/endpoint and body (make sure all required fields are included). Once you've done that, click on the HEADER tab. I want to make a header called basic Authorization e.g. (user: admin password: admin) .

Make a GET Request to workflow API endpoint

The figure below shows the GET Request at API endpoint GET request for List of workflow at API endpoint

retrieve from workflow api

Make a GET Request to comment API endpoint

The figure below shows the GET Request at API endpoint GET request for List of workflow at API endpoint

retrieve from comment api

Make a POST Request

Make a POST Request to workflow API endpoint

retrieve from workflow api

Make a POST Request to workflow API endpoint

retrieve from comment api Here we focus on discussions related to the user story.

Make a PUT Request

Make a PUT Request to workflow API endpoint

retrieve from workflow api

Make a PUT Request to workflow API endpoint

retrieve from comment api

Make a DELETE Request

Make a DELETE Request to workflow API endpoint

retrieve from workflow api

Make a DELETE Request to workflow API endpoint

retrieve from comment api

Known problems with solutions

sqlite3.OperationalError: no such table: workflowapp_workflow

python manage.py migrate --run-syncdb

About

This is a tutorial to build for workflow API using django

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published