Skip to content

Sanjaigiri/Hotel_Bokking

Repository files navigation

Hotel Booking System - Full Stack Django Project

A complete hotel booking management system built with Django, featuring user authentication with OTP verification, room booking, payment details, and receipt generation.

Features

1. User Authentication

  • Sign Up Page: Register with username, email, and password
  • OTP Verification: 6-digit OTP sent to user's Gmail for verification
  • Login Page: Secure login with email and password
  • User verification required before login

2. Home Page

  • Display all available rooms with pictures
  • Room types (Single, Double, Deluxe, Suite)
  • Price per night for each room
  • Room capacity and description
  • Beautiful responsive design
  • Navbar with Home, Book Now, Services, Contact Us links

3. Room Booking System

  • Book Now Page: Complete booking form
    • Guest name and email
    • Room type selection
    • Check-in and check-out date picker
    • Automatic calculation of:
      • Number of days
      • Price per night
      • Total amount
    • Bank details display
    • QR code generation for payment

4. Receipt Generation

  • Detailed booking receipt with:
    • Unique booking ID
    • Guest details
    • Room information
    • Check-in/Check-out dates
    • Payment breakdown
    • QR code for payment
    • Bank account details
    • Print functionality

5. Additional Pages

  • Services Page: Display all hotel amenities and services
  • Contact Us Page: Contact form and hotel information

Technology Stack

  • Backend: Django 6.0
  • Database: SQLite (can be changed to PostgreSQL/MySQL)
  • Frontend: HTML5, CSS3, JavaScript
  • Authentication: Django built-in auth with custom user model
  • Email: SMTP (Gmail)
  • QR Code: qrcode library
  • Image Handling: Pillow

Project Structure

Hotel_Booking/
├── booking/                    # Main Django app
│   ├── migrations/
│   ├── templates/
│   │   └── booking/           # HTML templates
│   │       ├── base.html      # Base template with navbar
│   │       ├── signup.html    # Registration page
│   │       ├── verify_otp.html # OTP verification
│   │       ├── login.html     # Login page
│   │       ├── home.html      # Homepage with rooms
│   │       ├── book_now.html  # Booking form
│   │       ├── receipt.html   # Booking receipt
│   │       ├── contact.html   # Contact page
│   │       └── services.html  # Services page
│   ├── models.py              # Database models
│   ├── views.py               # View functions
│   ├── urls.py                # URL routing
│   └── admin.py               # Admin configuration
├── hotel_project/             # Project settings
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── static/                    # Static files
│   ├── css/
│   │   └── style.css         # Main stylesheet
│   └── images/
├── media/                     # User uploaded files
│   ├── rooms/                # Room images
│   └── qrcodes/              # Generated QR codes
├── manage.py
├── .env.example              # Environment variables template
├── .gitignore
└── README.md

Installation & Setup

1. Prerequisites

  • Python 3.8 or higher
  • pip
  • Virtual environment (recommended)

2. Clone and Setup

# Navigate to project directory
cd D:\Django\Hotel_Booking

# Virtual environment is already created (.venv)
# Activate it if needed:
.venv\Scripts\activate

# Install dependencies (already done)
# pip install django pillow qrcode python-dotenv

3. Email Configuration

To enable OTP functionality, you need to configure Gmail SMTP:

  1. Go to your Google Account settings
  2. Enable 2-Step Verification
  3. Generate an App Password: https://myaccount.google.com/apppasswords
  4. Open hotel_project/settings.py and update:
EMAIL_HOST_USER = 'your-email@gmail.com'
EMAIL_HOST_PASSWORD = 'your-app-password'

Or create a .env file (copy from .env.example):

EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-app-password

4. Database Setup

# Migrations are already created and applied
# If you need to reset:
python manage.py makemigrations
python manage.py migrate

5. Create Superuser (Admin)

python manage.py createsuperuser

Follow the prompts to create an admin account.

6. Add Sample Rooms (via Admin)

# Run the development server
python manage.py runserver

Visit: http://127.0.0.1:8000/admin/

Login with superuser credentials and add rooms:

  • Navigate to "Rooms"
  • Click "Add Room"
  • Fill in details:
    • Name (e.g., "Ocean View Suite")
    • Room Type (Single/Double/Deluxe/Suite)
    • Description
    • Price per Night
    • Capacity
    • Upload Image (optional)
    • Check "Is Available"

7. Run the Application

python manage.py runserver

Access the application at: http://127.0.0.1:8000/

Usage Guide

For Users:

  1. Sign Up

    • Go to signup page
    • Enter username, email, and password
    • Check your email for OTP
    • Enter OTP to verify account
  2. Login

    • Use your email and password
    • Must be verified to login
  3. Browse Rooms

    • View available rooms on home page
    • See room types, prices, and amenities
  4. Book a Room

    • Click "Book Now" in navbar
    • Fill in guest details
    • Select room type
    • Choose check-in and check-out dates
    • Review calculated amount
    • Submit booking
  5. Payment & Receipt

    • View booking receipt
    • Scan QR code or use bank details for payment
    • Print receipt for records

For Admins:

  1. Access Admin Panel

  2. Manage Rooms

    • Add/Edit/Delete rooms
    • Upload room images
    • Set prices and availability
  3. Manage Bookings

    • View all bookings
    • Update booking status
    • Filter by date, status
  4. View Contact Messages

    • Check customer inquiries
    • Respond to messages

Database Models

CustomUser

  • Extended Django User model
  • Email-based authentication
  • OTP verification fields
  • Email unique constraint

Room

  • Room details (name, type, description)
  • Pricing and capacity
  • Image upload
  • Availability status

Booking

  • Guest information
  • Room selection
  • Check-in/Check-out dates
  • Auto-calculated amount
  • Unique booking ID
  • Status tracking

ContactMessage

  • Contact form submissions
  • Customer inquiries

Security Features

  • CSRF protection on all forms
  • Password hashing
  • Login required decorators for booking
  • OTP expiration (10 minutes)
  • Email verification required

Customization

Changing Bank Details

Edit in booking/templates/booking/book_now.html and receipt.html:

<p><strong>Bank Name:</strong> Your Bank Name</p>
<p><strong>Account Number:</strong> Your Account</p>
<p><strong>IFSC Code:</strong> Your IFSC</p>
<p><strong>UPI ID:</strong> your-upi@provider</p>

Styling

Modify static/css/style.css to customize:

  • Colors
  • Fonts
  • Layout
  • Responsive breakpoints

Email Templates

Edit email content in booking/views.py:

send_mail(
    'Your Custom Subject',
    'Your custom message',
    settings.EMAIL_HOST_USER,
    [email],
    fail_silently=False,
)

Deployment Checklist

Before deploying to production:

  1. Set DEBUG = False in settings.py
  2. Configure ALLOWED_HOSTS
  3. Use environment variables for sensitive data
  4. Setup PostgreSQL/MySQL database
  5. Configure static files serving
  6. Setup media files serving
  7. Enable HTTPS
  8. Configure proper email service
  9. Set strong SECRET_KEY
  10. Setup backup system

Troubleshooting

OTP Not Sending

  • Check Gmail app password
  • Verify EMAIL_HOST_USER and EMAIL_HOST_PASSWORD
  • Check if 2-Step Verification is enabled
  • Try with a different email service

Static Files Not Loading

python manage.py collectstatic

Database Issues

# Delete db.sqlite3 and migrations
# Then recreate:
python manage.py makemigrations
python manage.py migrate

Import Errors

pip install django pillow qrcode python-dotenv

Future Enhancements

  • Payment gateway integration
  • Email notifications for bookings
  • Room availability calendar
  • Reviews and ratings
  • Advanced search and filters
  • Multiple images per room
  • Booking cancellation
  • User profile management
  • Booking history
  • PDF receipt generation

Support

For issues and questions:

License

This project is for educational purposes.

Credits

Developed as a full-stack Django hotel booking system with complete authentication, booking management, and payment integration.


Note: Remember to configure your Gmail settings for OTP functionality before testing the signup feature!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors