This document provides step-by-step instructions on how to run and use the Django REST API endpoint for managing persons.
Before you begin, ensure you have the following prerequisites installed on your system:
- Python 3.x
- Django
- Django REST framework
- Postman (optional, for testing)
- Clone the repository containing your Django project to your local machine.
git clone [<repository_url>](https://github.com/Nazzcodek/person.git)
# Navigate to the project directory.
cd person
# Create and activate virtualenv
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Make Migrations.
python manage.py makemigrations
# Apply database migrations.
python manage.py migrate
# Start the development server.
python manage.py runserver
-
Open your web browser or a tool like Postman.
-
Access the API overview to see available endpoints:
- Perform CRUD operations:
-
Create a new person:
- Endpoint: https://stage-two-naziff.onrender.com/person/create/
- Method: POST
- Data: JSON object with a "name" field (e.g., {"name": "Mike Essien"})
-
View all persons:
- Endpoint: https://stage-two-naziff.onrender.com/person/all/
- Method: GET
-
Update a person:
- Endpoint: https://stage-two-naziff.onrender.com/person/update/int:pk/
- Method: POST
- Data: JSON object with a "name" field (e.g., {"name": "Updated Name"})
-
Delete a person:
- Endpoint: https://stage-two-naziff.onrender.com/person/person/int:pk/delete/
- Method: DELETE
-
swagger documentation:
You can use tools like Postman or use the API endpoints provided above.
successfully set up and run Django REST API endpoint for managing persons. This API can now be use to create, view, update, and delete person records.