django-display-ids
Stripe-style prefixed IDs for Django, like inv_2aUyqjCzEIiEcYMKj7TZtw, on top of the UUID fields you already have. No new fields and no migrations.
from django_display_ids import DisplayIDMixin, DisplayIDModel
class Invoice(DisplayIDModel):
display_id_prefix = "inv"
id = models.UUIDField(primary_key=True, default=uuid.uuid7)
slug = models.SlugField(unique=True)
invoice.display_id # "inv_2aUyqjCzEIiEcYMKj7TZtw"
class InvoiceDetailView(DisplayIDMixin, DetailView):
model = Invoice
The view now finds the invoice from the display ID, the UUID (550e8400-e29b-41d4-a716-446655440000, in either case) or the slug. Each one becomes a plain query on the UUID or slug column.
A UUID in a URL or log doesn't say what it points to; a display ID does. The part after the prefix is the same UUID in base62, so it converts back without a database lookup.
Django REST Framework
from django_display_ids.contrib.rest_framework import (
DisplayIDField,
DisplayIDMixin,
DisplayIDRelatedField,
)
class InvoiceSerializer(serializers.ModelSerializer):
display_id = DisplayIDField() # "inv_..."
customer = DisplayIDRelatedField(queryset=Customer.objects.all())
class Meta:
model = Invoice
fields = ("display_id", "customer", "total")
class InvoiceViewSet(DisplayIDMixin, ModelViewSet):
queryset = Invoice.objects.all()
serializer_class = InvoiceSerializer
The viewset finds invoices by display ID, UUID or slug. customer shows up as "cust_..." in responses and accepts the same in requests, so clients can send back what they read. With drf-spectacular, the fields and the viewset's {id} parameter get OpenAPI schemas.
Admin
from django_display_ids import DisplayIDAdminSearchMixin
@admin.register(Invoice)
class InvoiceAdmin(DisplayIDAdminSearchMixin, admin.ModelAdmin):
list_display = ["display_id", "name"]
search_fields = ["name"]
The admin search box finds invoices by display ID, UUID or slug, alongside the usual search.
Installation
pip install django-display-ids
pip install "django-display-ids[drf]" # with Django REST Framework
pip install "django-display-ids[spectacular]" # with DRF and drf-spectacular
Requires Python 3.12+ and Django 4.2+.
What's included
DisplayIDModelfor thedisplay_idproperty, and a manager withget_by_identifier(),filter_by_identifier(),get_by_identifiers()andresolve_uuid()resolve_object()andresolve_objects()to look up one or many identifiers anywhere elseDisplayIDMixinfor Django class-based views and for DRF viewsDisplayIDFieldandDisplayIDRelatedFieldfor DRF serializers, so APIs can both show and accept display IDs, with drf-spectacular schemasDisplayIDAdminSearchMixinto search the admin by display ID, UUID or slug- URL converters, and a
display_idtemplate filter for any UUID
Documentation
django-display-ids.readthedocs.io
Contributing
See CONTRIBUTING.md.
Related projects
These generate and store prefixed IDs in a new model field, where django-display-ids works with the UUID fields you already have:
- django-prefix-id: a
PrefixIDFieldthat stores base62-encoded UUIDs - django-spicy-id: a drop-in
AutoFieldreplacement - django-charid-field: a
CharFieldfor cuid, ksuid or ulid values
Metadata
Release files for django-display-ids 0.8.1
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 | Actions |
|---|---|---|---|---|
| django_display_ids-0.8.1.tar.gz | 29.5 kB | With provenance | Details for django_display_ids-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_display_ids-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for django_display_ids-0.8.1-py3-none-any.whl |
Total release size: 70.1 kB
Release files / django_display_ids-0.8.1.tar.gz
| Download URL | django_display_ids-0.8.1.tar.gz |
|---|---|
| Size | 29.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1a44be3b6fedd2fa0faae79f268fa5644af8db8f9f82180c1e30673722a8a73
|
|
BLAKE2b-256 checksum How to use checksums |
4c0c08593b625031cbcd6c2d4f9b819f17d443c9f0fa294d58e643e52cb20854
|
| 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 Sep 29, 2026.
Transparency logRelease files / django_display_ids-0.8.1-py3-none-any.whl
| Download URL | django_display_ids-0.8.1-py3-none-any.whl |
|---|---|
| Size | 40.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88109d1d2a8184639eabb83737ecdea6cfded7df40b7c4eea5e998adae9c0e64
|
|
BLAKE2b-256 checksum How to use checksums |
cc6a5115ae41aedc7faba9f009893d7bde6bec63f4efe03e5f048443a6237710
|
| 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 Sep 29, 2026.
Transparency logSecurity for django-display-ids 0.8.1
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
Both files in this release have been uploaded with provenance metadata.
Attestation for django_display_ids-0.8.1.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 Sep 29, 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.