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
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,
)
Custom generator
The base value is built by generate_namedid(instance, source_fields, separator). Pass generator to replace that function. It must use the same signature and return a string. Collision suffixes are still applied by the field.
# myapp/generators.py
from namedid import generate_namedid
def custom_namedid(instance, source_fields, separator):
base = generate_namedid(instance, source_fields, separator)
return f"org{separator}{base}" if base else base
named_id = NamedIDField(
source_fields=["name"],
generator="myapp.generators.custom_namedid",
max_length=200,
)
generator also accepts the callable itself. A dotted path is the form migrations can store unchanged.
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 uniqueeditable=False: Always read-onlyblank=False: Cannot be emptynull=False: Cannot be NULL
Development
./service.py dev install-dev
./service.py dev test
License
MIT
Metadata
Release files for django-namedid 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_namedid-1.2.0.tar.gz | 9.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_namedid-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.6 kB
Release files / django_namedid-1.2.0.tar.gz
| Download URL | django_namedid-1.2.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8ead42b16f96f79439b24eb58f48750ad487edfd32ede8d9a6ecbbf0a704584
|
|
BLAKE2b-256 checksum How to use checksums |
d09f5ff09a8c9effeb8b6ab8cf18a28a7897253cc7dbe721d83a2c04f0fa9e28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / django_namedid-1.2.0-py3-none-any.whl
| Download URL | django_namedid-1.2.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
379225cb2fa07074bb5021f55a8169d75aed3b0842f6d7cb338334de84e8dd6d
|
|
BLAKE2b-256 checksum How to use checksums |
d9fa45adb014549c150f78662b97fd9139370bd0b56312ff279c9521f5e4392d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logSecurity for django-namedid 1.2.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for django_namedid-1.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logA 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.