RentHub is a full-stack web application built with Django that enables users to browse, rent, and manage high-quality equipment. The project demonstrates advanced Django concepts including custom authentication, REST API, asynchronous tasks, and deployment.
Live Demo: renthub-django-production.up.railway.app
- Features
- Technical Stack
- Project Structure
- REST API
- Setup Instructions
- Environment Variables
- Running Tests
- Deployment
- Custom user model with email-based authentication (
AbstractBaseUser) - User registration, login, logout
- Profile management with profile picture upload (
ImageField) - Automatic profile creation via
post_savesignal - Welcome email sent on registration
- Full CRUD for rental items (create, read, update, delete)
- Item image upload
- Search by name and description (Q objects)
- Category filtering
- Custom template filter for currency formatting
- Many-to-many relationship between reservations and items
- Automatic total price calculation via model
@property - Custom form validation (end date must be after start date)
- Reservation confirmation email sent asynchronously via Celery
- Users can only view and edit their own reservations
- Each user has an auto-created wishlist (via
post_savesignal) - Toggle items in/out of wishlist from item detail page
- Wishlist count shown on profile page
- Users can add reviews to items
- Only review owners can edit or delete their review
- Nested display on item detail page
LoginRequiredMixinon all protected views- Custom
CheckUserIsOwnerandCheckUserIsItemOwnermixins - Two user groups in admin: Renters and Owners with distinct permissions
- Full CRUD API for Items and Reservations
- Custom
IsOwnerOrReadOnlypermission class - Session authentication
- Default permission:
IsAuthenticatedOrReadOnly
- Celery worker with Redis as message broker
django-celery-resultsfor task result storage in the database- Async email sending on reservation creation
- Custom
UserAdminwithAppUserCreationFormandAppUserChangeForm - Registered models:
AppUser,Profile,Item,Review,Reservation,Wishlist - Custom
list_display,list_filter,search_fieldson all models
- Environment variables via
python-dotenv - Separate
settings_production.pyfor production deployment - WhiteNoise for static file serving
dj-database-urlforDATABASE_URLparsing- Gunicorn as WSGI server
- HTTPS via Railway proxy (
SECURE_PROXY_SSL_HEADER)
| Layer | Technology |
|---|---|
| Backend | Django 6.0 (Python 3.12) |
| Frontend | Bootstrap 5.3, Django Template Language |
| Database | PostgreSQL 16+ |
| REST API | Django REST Framework |
| Async Tasks | Celery 5.x + Redis |
| Task Results | django-celery-results |
| Static Files | WhiteNoise |
| Deployment | Railway (Gunicorn) |
| Image Handling | Pillow |
renthub-django/
├── accounts/ # Custom user model, profile, authentication
│ ├── managers.py # AppUserManager (email-based auth)
│ ├── models.py # AppUser, Profile
│ ├── signals.py # Auto-create profile + send welcome email
│ ├── forms.py # Registration and profile edit forms
│ ├── views.py # Register, profile detail/edit/delete
│ └── admin.py # Custom UserAdmin
├── catalog/ # Items and reviews
│ ├── models.py # Item, Review
│ ├── api_views.py # DRF API views for items
│ ├── serializers.py # ItemSerializer, ReviewSerializer
│ └── management/commands/seed.py
├── bookings/ # Reservations
│ ├── models.py # Reservation (ManyToMany with Item)
│ ├── tasks.py # Celery task: send confirmation email
│ ├── api_views.py # DRF API views for reservations
│ └── serializers.py # ReservationSerializer
├── wishlist/ # User wishlists
│ ├── models.py # Wishlist (ManyToMany with Item)
│ └── signals.py # Auto-create wishlist on user registration
├── common/ # Shared utilities
│ ├── mixins.py # CheckUserIsOwner, CheckUserIsItemOwner
│ ├── permissions.py # IsOwnerOrReadOnly (DRF)
│ └── templatetags/ # custom_tags (currency filter)
└── renthub/ # Project configuration
├── settings.py
├── settings_production.py
├── celery.py
└── api_urls.py
Base URL: /api/
| Endpoint | Method | Auth Required | Description |
|---|---|---|---|
/api/items/ |
GET | No | List all items |
/api/items/ |
POST | Yes | Create item |
/api/items/<id>/ |
GET | No | Item detail |
/api/items/<id>/ |
PUT/PATCH | Owner only | Update item |
/api/items/<id>/ |
DELETE | Owner only | Delete item |
/api/reservations/ |
GET | Yes | List user's reservations |
/api/reservations/ |
POST | Yes | Create reservation |
/api/reservations/<id>/ |
GET | Yes | Reservation detail |
/api/reservations/<id>/ |
PUT/PATCH | Owner only | Update reservation |
/api/reservations/<id>/ |
DELETE | Owner only | Delete reservation |
1. Clone the repository:
git clone https://github.com/vivitoa/renthub-django.git
cd renthub-django2. Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows3. Install dependencies:
pip install -r requirements.txt4. Configure environment variables:
Create a .env file in the project root (see Environment Variables).
5. Create the PostgreSQL database:
psql -U postgres -c "CREATE DATABASE renthub_db;"6. Run migrations:
python manage.py migrate7. Seed the database:
python manage.py seed8. Create a superuser:
python manage.py createsuperuser9. Start Redis (required for Celery):
redis-server10. Start Celery worker (in a separate terminal):
celery -A renthub worker -l info11. Start the development server:
python manage.py runserverVisit http://127.0.0.1:8000
Create a .env file in the project root:
SECRET_KEY=your-secret-key-here
DB_NAME=renthub_db
DB_USER=postgres
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432
COMPANY_EMAIL=noreply@renthub.com
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
CELERY_BROKER_URL=redis://localhost:6379/0The
.envfile is listed in.gitignoreand will not be committed to version control.
python manage.py testThe test suite includes 22 tests covering:
- Model creation and validation
- Signal handlers (profile and wishlist auto-creation)
- View access control (login required, ownership checks)
- Form validation
- Celery task invocation (mocked with
unittest.mock.patch)
The application is deployed on Railway with:
- PostgreSQL and Redis as Railway services
- Gunicorn as the WSGI server
- WhiteNoise for static file serving
- dj-database-url for database configuration from
DATABASE_URL
Environment variables required in Railway:
| Variable | Value |
|---|---|
DJANGO_SETTINGS_MODULE |
renthub.settings_production |
SECRET_KEY |
your production secret key |
DATABASE_URL |
auto-provided by Railway Postgres |
REDIS_URL |
auto-provided by Railway Redis |
ALLOWED_HOSTS |
your Railway domain |
CSRF_TRUSTED_ORIGINS |
https://your-railway-domain |
Developed as an Individual Project for the Django Advanced Course @ SoftUni