Skip to main content

django-namedid

Django field that automatically combines multiple fields into a unique identifier with collision handling.

Purpose

Create unique identifiers by combining multiple model fields (e.g., name, id, date) with automatic collision resolution.

Installation

pip install django-namedid

Quick Start

Using NamedIDField directly

from django.db import models
from namedid import NamedIDField
from datetime import date

class Product(models.Model):
    name = models.CharField(max_length=100)
    code = models.IntegerField()
    created_date = models.DateField()
    
    named_id = NamedIDField(
        source_fields=["name", "code", "created_date"],
        max_length=200,
    )

Using the decorator

from django.db import models
from namedid import add_namedid

@add_namedid(named_id=["title", "id"], slug=["title", "category"])
class Article(models.Model):
    title = models.CharField(max_length=200)
    category = models.CharField(max_length=50)
    content = models.TextField()

Features

  • Automatic generation: Values are generated automatically before saving
  • Collision handling: Automatically appends numeric suffix if value exists (e.g., name-1-2023, name-1-2023-1, name-1-2023-2)
  • Type formatting: Automatically formats dates, numbers, booleans
  • Unique and required: Fields are always unique and cannot be empty
  • Read-only: Fields are automatically set to read-only

Field Properties

  • unique=True: Always unique
  • editable=False: Always read-only
  • blank=False: Cannot be empty
  • null=False: Cannot be NULL

Development

./service.py dev install-dev
./service.py dev test

License

MIT

Download files

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

Source Distribution

django_namedid-1.1.0.tar.gz (6.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_namedid-1.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file django_namedid-1.1.0.tar.gz.

File metadata

  • Download URL: django_namedid-1.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_namedid-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7ae7df153cb140ce0f9f9ea87e12aa135203cf6a5d865b3b1d72156e4e6beb6b
MD5 a64264355d56649cfde50be893a53d69
BLAKE2b-256 4075973a89b83fbc0f2d784685e646852784f910396192d152942c89f30d89fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_namedid-1.1.0.tar.gz:

Publisher: release.yml on octolo/django-namedid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_namedid-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_namedid-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_namedid-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfc0e015f2fd3cd361eb72ea2b66013a53f2248052b755c2682ee39e14025b6e
MD5 9aaac29a7eee634012efc478620d9e5c
BLAKE2b-256 5ebb562003e9f4fa1c878efa10f2005ebd28091981ac4baa215dce45e698cf5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_namedid-1.1.0-py3-none-any.whl:

Publisher: release.yml on octolo/django-namedid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

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