This Django REST Framework (DRF) project manages a library system with features like registration, authentication book listing, borrowing, and returning. with complete unit testing of models, serializers, and using Docker Containerization.
- Getting Started
- API Documentation
- Endpoint 1: Signup
- Endpoint 1: Get All User
- Endpoint 1: Login
- Endpoint 1: List All Books
- Endpoint 2: Borrow Book
- Endpoint 3: Return Borrowed Book
Make sure you have the following tools installed:
- Python (>=3.x)
- Django
- Django REST Framework
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/sunilnp2/library-management-drf.git cd library-management-drf
-
Run Docker Service:
docker compose build
-
Run docker-compose Services
docker compose up -d
-
Open Web interactive terminal (-it):
docker exec -it lms-container bash Migrate python manage.py makemigrations python manage.py migrate
-
Create Superuser:
python manage.py createsuperuser test@gmail.com test123
-
Open PostgreSQL interactive terminal
docker exec -it postgres_db psql -U postgres
The API will be accessible at http://localhost:8000
-
URL:
http://localhost:8000/auth/api/signup/
-
Method: POST
-
Authentication: No Auth
-
Data:
{ "name": "Sunil Nepali", "email": "sunil@gmail.com", "password": "test123" "password2": "test123" }
-
URL:
http://localhost:8000/auth/api/login/
-
Method: POST
-
Authentication: No Auth
-
Data:
{ "email": "sunil@gmail.com", "password": "test123" }
- URL:
http://localhost:8000/auth/api/getalluser/
- Method: Get
- Authentication: No Auth
- URL:
http://localhost:8000/auth/api/getuser/id/
- Method: Get
- Authentication: No Auth
-
URL:
http://localhost:8000/library/api/book_all_create/
-
Method: POST
-
Authentication: Basic Authentication
-
Permissions: CustomPermission - (IsAuthenticatedOrReadOnly)
-
Data:
{ "title": "Rich Dad Poor Dad", "isbn": "4354", "published_date": "2020-040-23" "genre": "finance" }
- URL:
http://localhost:8000/library/api/book_all_create/
- Method: Get
- Authentication: No Auth
- URL:
http://localhost:8000/library/api/book/id
- Method: Get
- Authentication: No Auth
-
URL:
http://localhost:8000/library/api/create-book-detail/
-
Method: POST
-
Authentication: Basic Auth
-
Permissions: CustomPermission - (IsAuthenticatedOrReadOnly)
-
Data:
{ "book": 1, "number_of_pages": 330, "publisher": "Asmita Publication", "language": "english" }
-
URL:
http://localhost:8000/library/api/book-detail/id/
-
Method: Patch
-
Authentication: Basic Auth
-
Permissions: CustomPermission - (IsAuthenticatedOrReadOnly)
-
Data:
{ "number_of_pages": 400, }
-
URL:
http://localhost:8000/library/api/borrowbook/
-
Method: POST
-
Authentication: Basic Auth
-
Permissions: CustomPermission - (IsAuthenticatedOrReadOnly)
-
Data:
{ "user": 1, "book": 1, }
- URL:
http://localhost:8000/library/api/list_borrowed_book/
- Method: Get
- Authentication: Basic Auth
- Permissions: CustomPermission - (IsAuthenticatedOrReadOnly)
-
URL:
http://localhost:8000/library/api/return-book/id/
-
Method: Put
-
Authentication: Basic Auth
-
Permissions: CustomPermission - (IsAuthenticatedOrReadOnly)
-
Data:
{ "returned_date": "2024-02-01" }