Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ozansz/drivebuddy-task

Driver model implementation using Django REST Framework
https://github.com/ozansz/drivebuddy-task

django django-rest-framework python rest-api

Last synced: 28 days ago
JSON representation

Driver model implementation using Django REST Framework

Awesome Lists containing this project

README

        

# drivebuddy-task

Driver model implementation using Django REST Framework

## Installation

Before cloning the repository, you need `django` and `djangorestframework` packages installed.

To install them, run the command below:

```bash
pip install django djangorestframework
```

Then, you can clone the repo:

```bash
git clone https://github.com/ozansz/drivebuddy-task
cd ./drivebuddy-task
```

And to run the server, run the command below:

```bash
python manage.py makemigrations drivers
python manage.py migrate
python manage.py runserver
```

## API

The RESTful API implements CRUD functionality for the `Driver` model.

### The Driver Model

The `Driver` model has three fields:



  • name - Name of the driver


  • email - Unique email of the driver


  • score - Score of the driver

### API Endpoints

The API endpoints for the `Driver` model are under the `/drivers` path.

#### Create driver

Request: `POST`

Path: `/drivers/`

Request body:

    `name`:

    `email`:

    `score`:


Response: `201 - Created`


#### Read driver

Request: `GET`

Path: `/drivers/`


Response: `200 - OK`

Response body:

    `url`:

    `name`:

    `email`:

    `score`:


#### Update driver

Request: `PUT`

Path: `/drivers/`

Request body:

    `name`:

    `email`:

    `score`:


Response: `200 - OK`

Response body:

    `url`:

    `name`:

    `email`:

    `score`:


#### Delete driver

Request: `DELETE`

Path: `/drivers/`


Response: `204 - No Content`

## Tests

There are 6 tests implemented to test the CRUD functionality of the API.

You can run the tests running the command below:

```bash
python manage.py test
```