A modern, feature-rich URL shortening service built with Django, featuring a beautiful glassmorphism UI, user authentication, analytics dashboard, and QR code generation.
- Glassmorphism Design: Beautiful dark theme with transparency effects and orange accents
- Responsive Layout: Works seamlessly on desktop, tablet, and mobile devices
- Smooth Animations: Interactive hover effects and transitions
- Clean Interface: Intuitive design with consistent styling across all pages
- User Registration & Login: Secure authentication system
- Personal Dashboard: Users can manage their shortened URLs
- Guest Access: Create short URLs without registration
- Session Management: Secure logout functionality
- Click Analytics: Track how many times each URL has been clicked
- User Dashboard: View all your created URLs in one place
- Statistics Overview: Total URLs created, total clicks, and recent activity
- Visual Charts: Interactive charts showing click trends and URL performance
- URL Shortening: Convert long URLs into short, shareable links
- Custom Short Codes: Automatically generated unique short codes
- URL Validation: Ensures only valid URLs are processed
- Redirect Tracking: Count and track click-through rates
- Dynamic QR Codes: Generate QR codes for any shortened URL
- High Quality: Vector-based QR codes with customizable size
- Download Option: Save QR codes as PNG images
- Mobile Friendly: Perfect for sharing via mobile devices
- CSRF Protection: Built-in Django security features
- Input Validation: Sanitized user inputs
- Error Handling: Graceful error pages and user feedback
- Database Integrity: Proper foreign key relationships and constraints
- Python 3.8 or higher
- pip (Python package installer)
- Git
-
Clone the repository
git clone https://github.com/huzaifa-asad/django-url-shortener.git cd django-url-shortener
-
Create a virtual environment
# Windows python -m venv env env\Scripts\activate # macOS/Linux python3 -m venv env source env/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Navigate to project directory
cd urlshortener
-
Run database migrations
python manage.py makemigrations python manage.py migrate
-
Create a superuser (optional)
python manage.py createsuperuser
-
Start the development server
python manage.py runserver
-
Open your browser Navigate to
http://localhost:8000
to start using the URL shortener!
django-url-shortener/
├── README.md
├── requirements.txt
└── urlshortener/
├── manage.py
├── db.sqlite3
├── app/
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── forms.py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ ├── utils.py
│ ├── views.py
│ ├── migrations/
│ └── templates/
│ ├── home.html
│ ├── success.html
│ ├── list.html
│ ├── analytics.html
│ ├── qr_code.html
│ └── auth/
│ ├── login.html
│ └── register.html
└── urlshortener/
├── __init__.py
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
-
As a Guest:
- Visit the homepage
- Enter your long URL in the input field
- Click "Shorten URL"
- Get your short URL instantly
-
As a Registered User:
- Register for an account or login
- Create short URLs with full tracking
- Access your personal dashboard
- View detailed analytics
- View All URLs: Click "My URLs" to see all your shortened links
- Track Performance: Use the analytics dashboard to monitor clicks
- Generate QR Codes: Create QR codes for any of your URLs
- Delete URLs: Remove URLs you no longer need
- Overview Stats: Total URLs created and total clicks
- Top Performing URLs: See which links get the most clicks
- Recent Activity: Monitor recent URL creation and usage
- Visual Charts: Interactive graphs showing trends over time
Endpoint | Method | Description |
---|---|---|
/ |
GET, POST | Homepage - Create short URLs |
/login/ |
GET, POST | User login |
/register/ |
GET, POST | User registration |
/logout/ |
POST | User logout |
/urls/ |
GET | List user's URLs |
/analytics/ |
GET | Analytics dashboard |
/analytics/data/ |
GET | JSON analytics data |
/<code>/ |
GET | Redirect to original URL |
/qr/<code>/ |
GET | Generate QR code image |
/qr/<code>/download/ |
GET | Download QR code |
/qr/<code>/page/ |
GET | QR code display page |
/delete/<id>/ |
POST | Delete URL |
Create a .env
file in the project root for production settings:
DEBUG=False
SECRET_KEY=your-secret-key-here
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
DATABASE_URL=sqlite:///db.sqlite3
Key settings in settings.py
:
ALLOWED_HOSTS
: Add your domain for productionDEBUG
: Set toFalse
for productionSECRET_KEY
: Use a secure secret keyDATABASES
: Configure your preferred database
-
Create Dockerfile:
FROM python:3.12-slim WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt COPY . . EXPOSE 8000 CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
-
Create docker-compose.yml:
version: '3.8' services: web: build: . ports: - "8000:8000" volumes: - .:/app
-
Run with Docker:
docker-compose up --build
- Web Server: Nginx
- WSGI Server: Gunicorn
- Database: PostgreSQL
- Cache: Redis
- Platform: Heroku, DigitalOcean, AWS, or VPS
- Configure production settings
- Set up database (PostgreSQL recommended)
- Configure static files serving
- Set up SSL certificate
- Configure domain and DNS
- Set up monitoring and logging
This project is licensed under the MIT License - see the LICENSE file for details.
Transform your long URLs into short, beautiful links with style!