A Django + DRF based car rental platform for customers, sellers, bookings, payments, offers, notifications, and dynamic content pages.
Car Rental System is a full-stack rental marketplace where customers can browse vehicles, check availability, book rentals, pay through Razorpay, manage booking history, and submit feedback. Sellers can manage their shop profile, vehicles, bookings, service status, offers, reviews, activity logs, and notifications.
This project provides both a web dashboard and REST APIs for a vehicle rental business.
- Browse available vehicles from the customer home page.
- Search and filter vehicles by city, brand, category, fuel type, transmission, and other vehicle data.
- View vehicle details, images, pricing, reviews, seller location, and related vehicles.
- Add or remove vehicles from favorites.
- Check booking availability before payment.
- Apply eligible offers or coupon codes.
- Create a Razorpay payment order.
- Confirm booking after successful payment verification.
- Track booking history and booking details.
- Cancel eligible bookings.
- Mark feedback and ratings after booking.
- View notifications and activity logs.
- Access dynamic pages like About Us, Privacy Policy, Refund Policy, Cancellation Policy, and Safety Guidelines.
- Access a protected seller dashboard.
- Manage seller shop profile and shop images.
- Add, edit, preview, and delete vehicles.
- Manage vehicle images, pricing, category, fuel type, transmission, color, registration, and location details.
- View seller dashboard counts for vehicles, bookings, payments, and reviews.
- View booking analytics and distribution analytics.
- Track booking requests and booking details.
- Mark vehicle as taken by customer.
- Mark vehicle as returned.
- Cancel bookings when required.
- Manage vehicle service records and service availability.
- View reviews for seller vehicles.
- View seller notifications and activity logs.
- Maintain Razorpay route/onboarding related seller payment details.
The application is split into multiple Django apps:
| App | Purpose |
|---|---|
core |
Shared models, seller dashboard pages, auth pages, vehicle data, booking records, seller activity, OTP tracking |
customer_portal |
Public/customer pages, dynamic templates, customer offers, favorites, contact form, notifications, customer activity |
drf_api |
Main REST API layer, serializers, viewsets, auth APIs, booking APIs, vehicle APIs, seller APIs |
payments |
Invoice, refund, commission, settlement, Razorpay utility logic, scheduled payment tasks |
datastorage |
Seller dashboard analytics APIs |
utils |
OTP, email, notification, pagination, and activity logging helpers |
- User signs up from
/signup/or through/api/signup/. - OTP is sent and verified through the email OTP APIs.
- User completes profile using
/complete-profile/or/api/complete-profile/. - User type decides the experience:
- Customer users continue to the customer portal.
- Seller users are redirected to the seller dashboard.
- Login uses JWT tokens for APIs and Django-rendered pages for web screens.
- Logout blacklists refresh tokens when used through the API.
- Customer opens the home page
/. - Vehicles are loaded from active seller listings.
- Customer searches or filters vehicles from
/search/. - Customer opens a vehicle detail page using
/vehicles/<vehicle_ref>/. - The system decodes the signed vehicle reference and loads the vehicle safely.
- Customer selects booking dates and checks availability.
- Availability checks consider:
- Existing active bookings
- Vehicle service windows
- Minimum booking days
- Maximum booking days
- Vehicle active/deleted status
- Seller active/deleted status
- Customer can apply an offer or coupon if eligible.
- Customer creates a Razorpay order through
/api/vehicle-bookings/payment-order/. - After payment, customer confirms the booking through
/api/vehicle-bookings/. - Payment signature is verified before the booking is created.
- Booking, invoice, activity logs, notifications, and emails are created.
- Customer can view booking history from
/booking-history/. - Customer can cancel eligible bookings and submit feedback after completion.
- Seller logs in and opens
/seller-dashboard/. - Seller dashboard shows vehicle, booking, payment, review, analytics, and highlight data from APIs.
- Seller manages vehicles from
/seller-dashboard/vehicles/. - Seller views bookings from
/seller-dashboard/bookings/. - For each booking, seller can:
- View details
- Mark vehicle as taken
- Mark vehicle as returned
- Cancel booking if allowed
- Vehicle handover updates notify the customer and update activity logs.
- Seller can manage service status so vehicles are blocked during maintenance.
Dynamic templates are stored in the database using the DynamicTemplate model in customer_portal.
Seeded dynamic pages include:
about-usour-storywhy-choose-usbooking-supportprivacy-policyterms-and-conditionsrefund-policycancellation-policysafety-guidelines
These pages are created by migrations and rendered through:
/pages/<slug>/
Example:
/pages/privacy-policy/
The footer links point to these dynamic page routes. When a user clicks a footer page link, Django calls DynamicTemplatePageView, loads the active template by slug, chooses the correct base layout, and renders templates/dynamic_templates/dynamic_page.html.
The dynamic page layout changes based on context:
?layout=authusesauth_base.html- Seller users use
base.html - Customers and public users use
customer/base.html
Dynamic template content is cached by slug. When a template is updated, deleted, or soft-deleted, its cache key is invalidated so users see fresh content.
The same dynamic template system is also used for mail content such as:
- Email verification OTP
- Reset password OTP
- Booking confirmation
- Booking cancellation
- Refund notification
- Vehicle taken
- Vehicle returned
- Vehicle return overdue
This allows email content to be managed from database records instead of hardcoding every email body in the view layer.
Payments are integrated with Razorpay.
Main payment flow:
- Customer checks vehicle availability.
- Customer creates a Razorpay order.
- Razorpay returns order details and key ID.
- Customer completes payment on the frontend.
- Backend verifies
razorpay_order_id,razorpay_payment_id, andrazorpay_signature. - Booking and invoice records are created only after payment verification.
Refund and settlement logic is handled through the payments app. The project includes models for:
- Commission settings
- Settlement grace periods
- Invoices
- Refund transactions
- Seller settlements
Celery tasks are used for background payment and refund related processing.
The system keeps separate activity and notification flows for customers and sellers.
- Booking created
- Booking cancelled
- Payment updates
- Vehicle handover updates
- Refund updates
- Favorite and feedback related activity
- New booking
- Booking cancellation
- Vehicle taken/returned
- Payment and settlement related updates
- Vehicle/service activity
Notification count APIs use Redis caching for faster dashboard updates.
- Backend: Django, Django REST Framework
- Auth: JWT with
djangorestframework-simplejwt, Django sessions, django-allauth - Database: PostgreSQL
- Cache / Broker: Redis
- Background Jobs: Celery, Celery Beat, django-celery-beat
- Payments: Razorpay
- Rich Text: CKEditor
- Filtering: django-filter
- Media: Django media uploads
- Containerization: Docker and Docker Compose
Car-Rental-System/
βββ Car_Rental_System/ # Django project settings, URLs, Celery config
βββ core/ # Core models, seller pages, auth pages
βββ customer_portal/ # Customer pages, dynamic templates, favorites, offers
βββ datastorage/ # Seller analytics APIs
βββ drf_api/ # REST APIs, serializers, filters, viewsets
βββ payments/ # Payment, invoice, refund, settlement logic
βββ templates/ # Django HTML templates
βββ static/ # Static assets
βββ media/ # Uploaded media files
βββ utils/ # Shared helper utilities
βββ Postman_API_collection/ # Postman collection and API docs
βββ docker-compose.yml
βββ Dockerfile
βββ requirements.txt
βββ .env.example
βββ README.md
This repository contains a real .env file, but it includes local secrets and should not be shared publicly. A safe sample file is provided:
.env.example
Create your local environment file:
cp .env.example .envThen update values like database credentials, email credentials, Redis URLs, and Razorpay keys.
Important environment variables:
| Variable | Description |
|---|---|
SECRET_KEY |
Django secret key |
DEBUG |
True for development, False for production |
ALLOWED_HOSTS |
Comma-separated allowed hosts |
DB_NAME |
PostgreSQL database name |
DB_USER |
PostgreSQL user |
DB_PASSWORD |
PostgreSQL password |
DB_HOST |
PostgreSQL host |
DB_PORT |
PostgreSQL port |
EMAIL_HOST_USER |
Gmail/SMTP email username |
EMAIL_HOST_PASSWORD |
SMTP app password |
CELERY_BROKER_URL |
Redis broker URL |
CELERY_RESULT_BACKEND |
Redis result backend URL |
REDIS_CACHE_URL |
Redis cache URL |
RAZORPAY_SERVER_ENV |
local, test, or live environment value |
RAZORPAY_TEST_API_KEY |
Razorpay test key ID |
RAZORPAY_TEST_API_SECRET_KEY |
Razorpay test secret |
RAZORPAY_LIVE_API_KEY |
Razorpay live key ID |
RAZORPAY_LIVE_API_SECRET_KEY |
Razorpay live secret |
Docker is the easiest way to run the full stack because it starts Django, PostgreSQL, Redis, Celery, and Celery Beat together.
docker compose up --buildOpen:
http://localhost:8000/
Django admin:
http://localhost:8000/admin/
Run in background:
docker compose up --build -dCreate admin user:
docker compose exec web python manage.py createsuperuserRun migrations manually: README.md
docker compose exec web python manage.py migrateRun tests:
docker compose exec web python manage.py testStop containers:
docker compose downRemove containers and volumes:
docker compose down -vRequirements:
- Python 3.12 recommended
- PostgreSQL
- Redis
Create virtual environment:
python -m venv venvActivate it on Windows:
venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtCreate .env from .env.example and update values.
Run migrations:
python manage.py migrateCreate admin user:
python manage.py createsuperuserStart Django:
python manage.py runserverStart Celery worker:
celery -A Car_Rental_System worker -l infoStart Celery Beat:
celery -A Car_Rental_System beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler| Route | Purpose |
|---|---|
/ |
Customer home |
/search/ |
Customer vehicle search |
/vehicles/<vehicle_ref>/ |
Customer vehicle detail |
/booking-checkout/ |
Customer booking checkout |
/booking-history/ |
Customer booking history |
/favorites/ |
Customer favorites |
/offers/ |
Customer offers |
/contact-us/ |
Contact/support page |
/pages/<slug>/ |
Dynamic template pages |
/login/ |
Login page |
/signup/ |
Signup page |
/complete-profile/ |
Complete profile page |
/profile/ |
User profile |
/seller-dashboard/ |
Seller dashboard |
/seller-dashboard/vehicles/ |
Seller vehicles |
/seller-dashboard/bookings/ |
Seller bookings |
/seller-dashboard/my-activity/ |
Seller activity |
The REST APIs are mounted mainly under:
/api/
There are also customer helper APIs under:
/customer/api/
Main API groups:
- Authentication and OTP
- Profile and license
- Vehicle master data
- Seller profile
- Vehicle CRUD
- Available vehicles
- Booking availability
- Booking payment order
- Booking creation
- Booking history and cancellation
- Vehicle handover and return
- Offers and coupons
- Feedback and reviews
- Customer favorites
- Notifications
- Activity logs
- Seller analytics
- Dynamic templates
The Postman collection is available in:
Postman_API_collection/Car_rental_system.postman_collection.json
See Postman_API_collection/README.md for collection usage notes.
The included Postman collection contains grouped requests for:
- Auth
- Customer user flow
- Seller user flow
- Dynamic templates
- Razorpay route testing
Set this collection variable before testing:
car_rental_base_url = http://localhost:8000/
For protected APIs, use:
Authorization: Bearer <access_token>
- The app uses soft-delete fields through shared
CommonFields. - Vehicle references in public URLs are signed instead of exposing raw IDs directly.
- Customer and seller dashboards are protected by role-aware mixins.
- Redis is used for cache-backed content like dynamic templates, offers, notifications, and customer home sections.
- Celery Beat schedules recurring cleanup, notification, refund, service reminder, and overdue tasks through migrations.
- Media files are stored under
media/. - Static collection output goes to
staticfiles/.
No sample env file existed before this documentation update. A proper .env.example has been added with safe placeholder values and all environment keys used by the current settings and Docker Compose configuration.
.env secrets to a public repository.