django-hashid-field
A Hashids obfuscated Django Model Field
What it is and what it does
Django-hashid-field is a custom Django model field that replaces integer primary keys or regular integer fields with hashid-encoded equivalents. It stores the actual integer in the database but exposes it as an obfuscated string (e.g., 'OwLxW8D' instead of 123), making IDs less predictable in URLs and APIs. The field supports filtering, lookups, and sorting by either the hashid string or the underlying integer, and can be dropped into existing models as a replacement for AutoField or IntegerField.
The package is built on top of the hashids library and integrates with Django's ORM, REST Framework, and admin interface. It supports per-field configuration of salt, alphabet, and prefix, as well as global settings. However, the package is now retired and explicitly marked as no longer recommended for new projects—the maintainer recommends migrating to alternatives.
Use it for:
- Replace sequential integer IDs in URLs with obfuscated strings to avoid exposing database size or ID patterns
- Add hashid-based primary keys to new Django models while maintaining integer storage for performance
- Migrate existing AutoField models to hashid equivalents while optionally allowing integer lookups during transition
- Prefix hashids with custom strings (e.g., 'user_h6ks82g') for human-readable, type-hinted API identifiers
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Django model field that obfuscates integer IDs using the Hashids library, storing integers in the database while exposing them as encoded strings.
No—not for new projects. The package is officially retired and the maintainer explicitly recommends against it. Existing projects using it do not require immediate changes, but should plan migration to an actively maintained alternative. The low install friction and permissive license do not offset the dormant maintenance status and explicit retirement notice.
Install
django-hashid-field on PyPI
pip
pip install django-hashid-fielduv
uv add django-hashid-fieldpoetry
poetry add django-hashid-fieldInstalling django-hashid-field
Before you install
Low install friction with only two runtime dependencies (Django and hashids). However, the package is dormant—last release was 2024-05-03 and no commits since then. The project is explicitly retired and no longer recommended for new projects; existing users should consider migrating.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it legally straightforward to adopt in most projects.
Quickstart
pip install django-hashid-field
# In settings.py:
HASHID_FIELD_SALT = "a long and secure salt value that is not the same as SECRET_KEY"
# In models.py:
from hashid_field import HashidField
from django.db import models
class Book(models.Model):
reference_id = HashidField()
# Usage:
b = Book.objects.create()
print(b.reference_id) # Hashid(1): OwLxW8D
Requires Django and hashids as runtime dependencies; requires a configured HASHID_FIELD_SALT in Django settings.
Verify before relying
- Whether the retirement affects compatibility with Django 5.0 or newer Python versions in practice
- Migration path recommendations for projects currently using this package
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Django, hashids |
| Maintenance | dormant — 833 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 190,549/month — #9,906 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_hashid_field-3.4.1-py3-none-any.whl
Keywords: django, hashids, hashid
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
django-hashidsProvides a Django model field that proxies…
permissive · top 15,000 on PyPI
django-sqidsAdds a Django model field that encodes primary…
permissive · top 15,000 on PyPI
hashidsGenerates short, unique, non-sequential hashes…
permissive · top 5,000 on PyPI
django-deprecate-fieldsProvides a decorator to mark Django model…
permissive · top 5,000 on PyPI
django-fernet-encrypted-fieldsProvides Django model fields that encrypt data…
unclear · top 15,000 on PyPI
django-cryptography-5Provides encrypted model fields and…
permissive · top 15,000 on PyPI
django-cryptographyWraps Python's cryptography library to add…
permissive · top 15,000 on PyPI
django-cryptography-django5Encrypts and decrypts data in Django models…
permissive · top 15,000 on PyPI
drf-writable-nestedExtends Django REST Framework serializers to…
permissive · top 15,000 on PyPI
django-picklefieldProvides a Django model field that stores and…
permissive · top 5,000 on PyPI