Skip to main content

django-shortuuid

PyPI PyPI - Implementation GitHub License Build

A drop-in Django model field for generating short, URL-safe, and unique IDs using shortuuid.
Customizable, migration-friendly, with optional collision detection and Django admin integration.

Features

  • Short, URL-safe unique IDs for Django models (default 22 characters, configurable)
  • Customizable alphabet, prefix, and length
  • Optional database collision detection and retry logic
  • Django admin: field is read-only but visible
  • Compatible with Django migrations
  • Python type hints

Installation

pip install django-shortuuid

Usage

from django.db import models
from django_shortuuid.fields import ShortUUIDField

class MyModel(models.Model):
    id = ShortUUIDField(primary_key=True, prefix="id-")
    # ... other fields ...

By default, auto=True generates a unique short UUID when each instance is saved, and makes the field read-only in forms/admin.

Example

See django_example/ for a full Django setup and admin usage.

Configuration

  • auto: Generate and set value automatically (True by default)
  • length: Length of the generated unique string (default 22)
  • prefix: Optional string prefix for the field value
  • alphabet: Custom alphabet for uuid generation (default: shortuuid’s default)
  • collision_check: Enables collision checking in the database (True by default)
  • max_retries: Max attempts to generate unique value before error (10 by default)

License

MIT Copyright (c) stabldev

Credits

This project was inspired by benrobster/django-shortuuidfield
and builds on ideas from the original implementation.

Special thanks to shortuuid for the short, URL-safe UUID generation.

Metadata

Release files for django-shortuuid 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-shortuuid 0.1.2
File Size Uploaded Provenance Actions
django_shortuuid-0.1.2.tar.gz 2.9 kB Without provenance Details for django_shortuuid-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-shortuuid 0.1.2
File Interpreter ABI Platform Actions
django_shortuuid-0.1.2-py3-none-any.whl Python 3 none any Details for django_shortuuid-0.1.2-py3-none-any.whl

Total release size: 6.6 kB

Release files / django_shortuuid-0.1.2.tar.gz

Download URL django_shortuuid-0.1.2.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8038af51e614dfd8f870343787a274fe4570897bb64261efba6f751e173c629c
BLAKE2b-256 checksum
How to use checksums
742224c4e9f64a1255cdd132c51e604894ee99295cda3231a0b269dc81b08142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.22

Release files / django_shortuuid-0.1.2-py3-none-any.whl

Download URL django_shortuuid-0.1.2-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
623e7607133d3fbf1031af0944f2cdf3a62af723fb0f5250c508876205be0aaf
BLAKE2b-256 checksum
How to use checksums
c06159af2881cab219437b3913fbf77f11d299cbdf1a05faeb7b71cf86a86236
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.22

Security for django-shortuuid 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page