Video Link
This GitHub repository hosts a Django project with Django Rest Framework that creates a RESTful API for managing books. It meets the following project requirements:
☑ offering operations to list all books,
☑ retrieve books by ID,
☑ add new books,
☑ update existing ones,
☑ and delete entries.
Furthermore, it extends functionality to allow:
☑ partial updates of book records.
This includes endpoints for specific field updates with thorough validation, ensuring data integrity.
Error responses are provided for invalid input.
This repository serves as a practical demonstration of building a robust RESTful API using Django and Django Rest Framework, showcasing features like partial updates and data validation.
Before you begin, ensure you have the following installed:
- Python: Download and install Python
- Git: Download and install Git
- Clone the repository to your local machine, and navigate into it,
git clone [email protected]:prabhxjottsingh/book-api.git
cd .\book-api\
2.Create a .env file in the project root directory using the following terminal command and enter the virtual enviroment,
virtualenv venv
venv/scripts/activate
- Install project dependencies by running,
pip install -r requirements.txt
- Activate the database and make the migrations,
python manage.py makemigrations
python manage.py migrate
- In the end, don't forget to get out of the virtual environment using the command,
deactivate
To start the Bookstore Management System on local system, use the following command:
python manage.py runserver
This will start the server, and you should see a message indicating that the server is running on the specified port.
The system provides the following API endpoints for managing CRUD operation, along with validation:
GET /books : Retrieve all books
GET /books/{id} : Retrieve single book by id
POST /books/ : Create a new Book
DELETE /books/{id} : DELETE an existing book
PUT /books/{id}/partial-update/ : Partially update an existing book
Creating or updating a book with wrong information will give an error.
The system uses the following main dependencies:
Python: A versatile and high-level programming language.
Django: A Python web framework for building web applications.
Django Rest Framework: A powerful tool for creating RESTful APIs in Django.
You now have the Bookstore Management System up and running on your local machine. Use the provided API endpoints to manage book records in your bookstore.
Customize and extend the system according to your needs.