A Django app to create and manage URL shortener codes
Project description
Django URL Shortener
A reusable Django app that provides URL shortening functionality. It allows you to create short codes that redirect to longer URLs and manage them through Django's admin interface.
Features
- Create custom codes for URLs or auto-generate random ones
- Track usage statistics for each shortened URL
- Full admin interface integration
- Simple to integrate with existing Django projects
Requirements
- Python 3.9+
- Django 3.2+
Installation
pip install django-url-shortener
Quick start
- Add "url84t_shortener" to your INSTALLED_APPS setting:
INSTALLED_APPS = [
...
'url84t_shortener',
]
- Include the url84t_shortener URLconf in your project urls.py:
from django.urls import path, include
urlpatterns = [
...
path('', include('url84t_shortener.urls')),
]
-
Run
python manage.py migrateto create the necessary database tables. -
Start the development server and visit http://127.0.0.1:8000/admin/ to create a short URL (you'll need the Admin app enabled).
-
Visit http://127.0.0.1:8000/code/yourcode to be redirected to the destination URL.
Usage
Creating short URLs via the admin interface
- Navigate to the Django admin interface
- Go to the "Short URLs" section
- Click "Add Short URL"
- Enter a code or leave it blank for auto-generation
- Enter the destination URL
- Save
Using in templates
You can generate links to your short URLs in templates:
<a href="{% url 'url84t_shortener:redirect' 'yourcode' %}">Your short link</a>
Or using the model instance:
<a href="{{ short_url.get_absolute_url }}">Your short link</a>
License
Bitcoin address: bc1qnfv6uwpu6g6t45s3ns2xrsx4m7qulshp4g07kj
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_url84t_shortener-0.2.0.tar.gz.
File metadata
- Download URL: django_url84t_shortener-0.2.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3861e6610a26b36b7c1885b03c14a17cdfc512fbbae2647f915b1508a1d4d425
|
|
| MD5 |
c425e04d3acc503e27e3ee866be8c2f6
|
|
| BLAKE2b-256 |
467a743d3f18f008856dbaf028d785d26d882fee44f5e850c5786c229e91169e
|
File details
Details for the file django_url84t_shortener-0.2.0-py3-none-any.whl.
File metadata
- Download URL: django_url84t_shortener-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
580d3d05548e99805a7334a28ce910daab4067f101f7d13efab6c1db131096cd
|
|
| MD5 |
f466e1c142d78f3004f7681b860f46ee
|
|
| BLAKE2b-256 |
2239fc570d754d390f0f1d8cdb99f69b6e5cf79f4d455ce91b35533b7aa96e28
|