Skip to content

A CRUD REST API for a Person model using Django, Django Rest Framework, CORS Headers ...

Notifications You must be signed in to change notification settings

Tomilola-ng/TrackBackendTask2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HNGx CRUD Person REST API

This is a Django REST API project that allows you to manage and interact with a "Person" resource. You can perform CRUD (Create, Read, Update, Delete) operations on individuals' data.

Table of Contents

Getting Started

UML Diagram for the CRUD Person REST API

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/Tomilola-ng/TrackBackendTask2.git
cd my-awesome-api
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Apply database migrations:
python manage.py migrate
  1. Start the development server:
python manage.py runserver

Your API should now be running locally at http://localhost:8000/.

Usage

To use the API, you can make HTTP requests to the provided endpoints. Here's an overview of the available endpoints:

API Endpoints

  • POST /api: Create a new person.
  • GET /api/<user_id>: Retrieve details of a person by their ID.
  • PUT /api/<user_id>: Update details of an existing person.
  • DELETE /api/<user_id>: Remove a person.

Example Requests

  • Create a new person:
POST http://localhost:8000/api
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com"
}
  • Retrieve details of a person:
GET http://localhost:8000/api/1
  • Update details of a person:
PUT http://localhost:8000/api/1
Content-Type: application/json
{
"name": "Updated John Doe",
"email": "updated_john@example.com"
}
  • Remove a person:
DELETE http://localhost:8000/api/1

Testing

To run the test suite, use the following command:

python manage.py test

Documentation

For detailed information on how to use this API, check the API Documentation file.

About

A CRUD REST API for a Person model using Django, Django Rest Framework, CORS Headers ...

Topics

Resources

Stars

Watchers

Forks

Languages