Skip to main content

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

  1. Add "url_shortener" to your INSTALLED_APPS setting:
INSTALLED_APPS = [
    ...
    'url_shortener',
]
  1. Include the url_shortener URLconf in your project urls.py:
from django.urls import path, include
urlpatterns = [
    ...
    path('', include('url_shortener.urls')),
]
  1. Run python manage.py migrate to create the necessary database tables.

  2. 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).

  3. Visit http://127.0.0.1:8000/code/yourcode to be redirected to the destination URL.

Usage

Creating short URLs via the admin interface

  1. Navigate to the Django admin interface
  2. Go to the "Short URLs" section
  3. Click "Add Short URL"
  4. Enter a code or leave it blank for auto-generation
  5. Enter the destination URL
  6. Save

Using in templates

You can generate links to your short URLs in templates: <a href="{% url 'url_shortener:redirect' 'yourcode' %}">Your short link</a>

Or using the model instance: <a href="{{ short_url.get_absolute_url }}">Your short link</a>

License

License: Coffee-1.1 Buy me a coffee Send me a bitcoin

Bitcoin address: bc1qnfv6uwpu6g6t45s3ns2xrsx4m7qulshp4g07kj

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_url84t_shortener-0.1.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_url84t_shortener-0.1.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file django_url84t_shortener-0.1.1.tar.gz.

File metadata

  • Download URL: django_url84t_shortener-0.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for django_url84t_shortener-0.1.1.tar.gz
Algorithm Hash digest
SHA256 91b4230c87fe7c578ff4d86c665c13b32893fab33d5f7466e15afe6c6f2ace53
MD5 21a4db5ed291fdbd62662ef61859da5d
BLAKE2b-256 d18e563df0974cb0bb4b95ca0ab5b8943a2d01970ff3ef82798c5933c40d7153

See more details on using hashes here.

File details

Details for the file django_url84t_shortener-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_url84t_shortener-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8207129653fb8641d4a6dc0693378f36f0bdb067b373819e6b86c82288389f7
MD5 ea869560c36892bde891c1b3332c1cd4
BLAKE2b-256 a5537d3810bff6cf58034c4213f53755f0d1ae0d9cd0ab5a8375c2f7b8108f28

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page