This project demonstrates the implementation of a Library Management System using Django, incorporating soft delete functionality through the django-safedelete package. It includes multiple models, a Django REST Framework (DRF) API, and basic CRUD operations.
- library_project: Django project directory.
- library: Django app containing models, views, serializers, and URLs.
-
Clone the repository:
git clone https://github.com/MehediMK/django-safedelete.git cd library_project
-
Create and activate a virtual environment:
# Create virtual environment python3 -m venv venv # Activate virtual environment (Linux/Mac) source venv/bin/activate # Activate virtual environment (Windows) venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Apply database migrations:
python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
-
To load dummy data which was existing in fixtures directory
python manage.py loaddata authors.json
python manage.py loaddata books.json
- Access the Django admin interface at
http://127.0.0.1:8000/admin/
to add authors and books.
To run the project using Docker, follow these steps:
-
Make sure Docker is installed on your system. If not, you can download and install Docker from here.
-
Build the Docker image and start the container:
docker-compose up --build
-
Access the Django project at
http://localhost:8000
.
- Soft Delete: Utilizes django-safedelete to implement soft delete functionality, allowing records to be marked as deleted without physically removing them from the database.
- RESTful API: Provides CRUD operations for authors and books through a DRF API.
- Admin Interface: Allows easy management of library data through the Django admin interface.
- Fixture Data: Included fixture files provide sample data for authors and books to quickly populate the database.
- Create superuser:
python manage.py createsuperuser
- Visit
http://127.0.0.1:8000/admin/
- Log in with superuser credentials.
- Add authors and books through the admin interface.
- Authors:
http://127.0.0.1:8000/api/authors/
- Books:
http://127.0.0.1:8000/api/books/
Feel free to customize this README file further based on your project's specific details and requirements!