Skip to main content

Prefixed unique ID field for Django models

Project description

django-puid

A Django field that generates human-friendly prefixed unique IDs — a readable alternative to UUIDs.

usr_lrjk8xq2a3b9f
order_lrjk8xr7z91mk

IDs are time-sortable (timestamp in base36) with a cryptographically random suffix, so they're both friendly and collision-resistant.

Installation

pip install django-puid

Usage

from django_puid.fields import PrefixedUIDField

class Order(models.Model):
    uid = PrefixedUIDField(prefix="order")

This adds a uid field that auto-generates on save and does not replace Django's default integer primary key.

Options

Parameter Default Description
prefix required String prepended to the ID
separator "_" Character between prefix and ID body
random_length 6 Number of random characters in the suffix
# Custom separator and length
uid = PrefixedUIDField(prefix="usr", separator="-", random_length=8)
# → usr-lrjk8xq2a3b9f1z

ID format

{prefix}{separator}{timestamp_base36}{random_suffix}
      usr _ lrjk8xq 2a3b9f
  • Timestamp — milliseconds since epoch encoded in base36 (~8 chars, grows slowly)
  • Random suffix — cryptographically random base36 characters (secrets module)

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_puid-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

django_puid-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file django_puid-0.1.0.tar.gz.

File metadata

  • Download URL: django_puid-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_puid-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8099c2348b05aa9c68257878dc326371650719e56c99f20cf66533fd113b601f
MD5 1c2d31a3f05ff017c32f2b166658be01
BLAKE2b-256 a41d45fe7fbbcf072a803286be95673dafc3884cda2788eb7a07d09cb50f14e9

See more details on using hashes here.

File details

Details for the file django_puid-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_puid-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_puid-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d714acf0bb70ef2a5488b3ed3331bdff478f09d8288de36d7909b6245c51386
MD5 095e6bb8f1d8d2d3bc392d28249183ec
BLAKE2b-256 0a3f28341cc4c576cb509563879675abf77b528a8f6e453aaf5838e1cd63a26a

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