A modern, feature-rich URL shortener built with Django and Python. Create custom short links, track analytics, and generate QR codes with a stunning glassmorphism UI.
✨ Core Features
- 🔗 Shorten long URLs instantly
- 🎨 Custom short codes for branded links
- ⏰ Optional URL expiration
- 📊 Real-time click tracking and analytics
- 📱 QR code generation for easy sharing
- 🎯 Clean, intuitive dashboard
🎨 Premium UI/UX
- Modern glassmorphism design
- Smooth animations and transitions
- Fully responsive layout
- Dark theme with vibrant gradients
- Interactive micro-animations
- Backend: Django 5.0.1
- Database: SQLite (easily switchable to PostgreSQL/MySQL)
- Frontend: HTML5, CSS3, Vanilla JavaScript
- QR Codes: qrcode library
- Styling: Custom CSS with modern design patterns
-
Clone or navigate to the project directory
cd "c:\Users\akash\OneDrive\Desktop\url shortener"
-
Install dependencies
pip install -r requirements.txt
-
Run migrations
python manage.py migrate
-
Create a superuser (optional, for admin access)
python manage.py createsuperuser
-
Start the development server
python manage.py runserver
-
Access the application
You can add this to your local and run it.
- Navigate to the home page
- Enter your long URL
- (Optional) Click "Advanced Options" to:
- Set a custom short code
- Set an expiration date
- Click "Shorten"
- Copy your new short URL or generate a QR code
- Go to the Dashboard
- View all your shortened URLs with statistics
- Actions available:
- Copy: Copy the short URL to clipboard
- QR Code: Generate and download QR code
- Stats: View detailed analytics
- Delete: Remove the URL
Simply visit any short URL (e.g., http://127.0.0.1:8000/abc123) and you'll be automatically redirected to the original URL. Each click is tracked for analytics.
url shortener/
├── manage.py
├── requirements.txt
├── README.md
├── db.sqlite3
├── urlshortener/ # Project settings
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── shortener/ # Main app
├── migrations/
├── templates/
│ └── shortener/
│ ├── base.html
│ ├── home.html
│ ├── dashboard.html
│ └── expired.html
├── __init__.py
├── admin.py
├── models.py
├── views.py
└── urls.py
POST /api/create/- Create a new short URLGET /api/stats/<short_code>/- Get URL statisticsDELETE /api/delete/<short_code>/- Delete a URLGET /qr/<short_code>/- Generate QR codeGET /<short_code>/- Redirect to original URL
original_url: The long URL to shortenshort_code: Unique short codecreated_at: Creation timestampexpires_at: Optional expiration dateclicks: Click counteris_active: Active statuscustom_code: Whether it's a custom code
url: Foreign key to URLclicked_at: Click timestampip_address: Visitor IPuser_agent: Browser informationreferrer: Referring URL
Edit the CSS variables in shortener/templates/shortener/base.html:
:root {
--primary: #6366f1;
--secondary: #ec4899;
--accent: #14b8a6;
/* ... more colors */
}To use PostgreSQL or MySQL, update DATABASES in urlshortener/settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'your_db_name',
'USER': 'your_db_user',
'PASSWORD': 'your_password',
'HOST': 'localhost',
'PORT': '5432',
}
}For production deployment:
- Set
DEBUG = Falsein settings.py - Configure
ALLOWED_HOSTS - Set up a production database
- Configure static files with
collectstatic - Use a production server (Gunicorn, uWSGI)
- Set up a reverse proxy (Nginx, Apache)
- CSRF protection enabled
- SQL injection prevention (Django ORM)
- XSS protection
- Secure password hashing
- Clickjacking protection
- User authentication and personal dashboards
- Bulk URL shortening
- Advanced analytics (geographic data, device types)
- API rate limiting
- Custom domains
- Link preview before redirect
- Browser extension
This project is open source and available under the MIT License.
For issues, questions, or contributions, please create an issue in the repository.
Built with ❤️ using Django and Python