Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomilola-ng/trackbackendtask2
A CRUD REST API for a Person model using Django, Django Rest Framework, CORS Headers ...
https://github.com/tomilola-ng/trackbackendtask2
cors-headers crud django django-rest-framework postgresql python
Last synced: about 8 hours ago
JSON representation
A CRUD REST API for a Person model using Django, Django Rest Framework, CORS Headers ...
- Host: GitHub
- URL: https://github.com/tomilola-ng/trackbackendtask2
- Owner: Tomilola-ng
- Created: 2023-09-11T19:21:20.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-12T21:52:01.000Z (about 1 year ago)
- Last Synced: 2023-09-13T04:23:25.582Z (about 1 year ago)
- Topics: cors-headers, crud, django, django-rest-framework, postgresql, python
- Language: Python
- Homepage: https://hngx-backend-track-task2.onrender.com/api/
- Size: 157 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [API Endpoints](#api-endpoints)
- [Testing](#testing)
- [Deployment](#deployment)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [License](#license)
## Getting Started
![UML Diagram for the CRUD Person REST API](./UML.png)
### Prerequisites
- [Python](https://www.python.org/downloads/) (3.10 or higher)
- [Django](https://www.djangoproject.com/) (3.0 or higher)
- [Django Rest Framework](https://www.django-rest-framework.org/)
- [Git](https://git-scm.com/)
### Installation
1. Clone the repository:
```bash
git clone https://github.com/Tomilola-ng/TrackBackendTask2.git
cd my-awesome-api
```
2. Create and activate a virtual environment:
```bash
python -m venv venv
source venv/bin/activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
4. Apply database migrations:
```bash
python manage.py migrate
```
5. Start the development server:
```bash
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/`: Retrieve details of a person by their ID.
- `PUT /api/`: Update details of an existing person.
- `DELETE /api/`: Remove a person.
### Example Requests
- Create a new person:
```http
POST http://localhost:8000/api
Content-Type: application/json
{
"name": "John Doe",
"email": "[email protected]"
}
```
- Retrieve details of a person:
```http
GET http://localhost:8000/api/1
```
- Update details of a person:
```http
PUT http://localhost:8000/api/1
Content-Type: application/json
{
"name": "Updated John Doe",
"email": "[email protected]"
}
```
- Remove a person:
```http
DELETE http://localhost:8000/api/1
```
## Testing
To run the test suite, use the following command:
```bash
python manage.py test
```## Documentation
For detailed information on how to use this API, check the [API Documentation](DOCUMENTATION.md) file.