A simple and efficient URL shortening application built with Django. This app allows users to shorten long URLs, track their usage, and manage the links.
- Shorten long URLs into concise, shareable links.
- Redirect users seamlessly from the shortened URL to the original URL.
- Track the number of clicks on each shortened link.
- User authentication and ownership for secure link management.
- API endpoints for creating, retrieving, updating, and deleting shortened links.
git clone [email protected]:mertcan-tas/django-url-shortener.git
python -m venv env
source env/bin/activate # On Windows, use `env\Scripts\activate`
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
Open your browser and go to http://127.0.0.1:8000.
The app provides RESTful API endpoints for managing shortened links:
Method | Endpoint | Description |
---|---|---|
POST | /api/shortened-links/create/ | Create a new shortened link |
GET | /get// | Redirect to the original URL |
GET | /api/shortened-links/user/ | List all shortened links of the user |
DELETE | /api/shortened-links/uuid/delete/ | Delete a specific shortened link |
PUT/PATCH | /api/shortened-links/uuid/update/ | Update a specific shortened link |
POST | /api/account/register | Login |
POST | /api/account/login | Register |
The shortened URL IDs are generated using the ShortUUIDField. You can customize the length, character set, and format by editing the ShortenedLink model in models.py.
The redirection logic is implemented in ShortenedLinkGetAPIView. You can modify it to include custom logging, analytics, or additional features.
Future Enhancements
- Add analytics for detailed tracking of clicks by date and location.
- Implement bulk link creation for advanced users.
- Add expiration dates to links with automatic cleanup.
- Enhance the frontend for a user-friendly experience.
We welcome contributions! Please fork this repository and submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.