A simple web application built with Django for managing a bookstore. Users can browse books, view details, register, login/logout, and add books to a session-based shopping cart. A custom admin panel allows staff users to add, edit, and delete books from the inventory.
This project adheres to specific constraints, including using only Class-Based Views and manual HTML forms (no Django Forms or built-in Admin for book management).
- Backend: Python, Django
- Frontend: HTML, CSS, Bootstrap 5 (via CDN)
- Database: SQLite (default for development)
- DevOps: Docker, Docker Compose, Jenkins (configuration included)
- Version Control: Git, GitHub
- Python 3.8+
- Pip (Python package installer)
- Git
- Docker & Docker Compose (Recommended)
- Jenkins (Optional, for CI/CD pipeline)
- Clone the Repository:
git clone <your-repository-url> cd bookstore-project # Or your repo name
- Create Environment File:
Create a
.env.devfile in the root directory (copy from.env.exampleif provided, or create manually):(EnsureSECRET_KEY=your_strong_random_secret_key DEBUG=True
.env.devis in your.gitignore) - Build and Run:
The
docker-compose up --build -d
--buildflag ensures the image is built.-druns it in detached mode. - Apply Migrations (First time or after model changes):
Run migrations inside the running container:
docker-compose exec web python manage.py migrate - Create Superuser (for Admin Panel Access):
Run this command inside the container:
Follow the prompts to create an admin user.
docker-compose exec web python manage.py createsuperuser - Access the Application:
Open your web browser and navigate to
http://localhost:8000orhttp://127.0.0.1:8000. Access the custom admin panel athttp://localhost:8000/manage/books/(login with your superuser).
- Clone the Repository:
git clone <your-repository-url> cd bookstore-project # Or your repo name
- Create Virtual Environment:
python -m venv venv # Activate: # Windows: .\venv\Scripts\activate # macOS/Linux: source venv/bin/activate
- Install Dependencies:
pip install -r requirements.txt
- Apply Migrations:
python manage.py migrate
- Create Superuser:
python manage.py createsuperuser
- Run the Development Server:
python manage.py runserver
- Access the Application:
Open your web browser and navigate to
http://127.0.0.1:8000. Access the custom admin panel athttp://127.0.0.1:8000/manage/books/.
(Insert screenshots of key pages here if available/required)
- Home Page
- Book List
- Book Detail
- Shopping Cart
- Login Page
- Registration Page
- Custom Admin Book List
- Docker: The
Dockerfilesets up the Python environment and copies the application code.docker-compose.ymldefines thewebservice to run the Django application and manages a volume for the SQLite database persistence. Environment variables likeSECRET_KEYandDEBUGcan be managed via the.env.devfile for local development. - Jenkins: The
Jenkinsfileprovides a basic declarative pipeline structure for CI/CD. It includes placeholder stages for Checkout, Build (using Docker Compose), Test (requires test implementation), and Deploy (requires specific deployment scripts/configuration). You will need to configure Jenkins with appropriate plugins (Docker, Pipeline, Git, SSH Agent if needed) and potentially set up credentials for Docker Hub or deployment targets. Run tests usingdocker-compose run --rm web python manage.py test bookstore(after writing tests).
