django-hashids
Non-intrusive hashids library for Django
Decision gist · record as of 2026-08-14
Yes, if you need to expose non-sequential IDs in URLs or APIs without database changes. The low install friction, permissive license, and transparent ORM integration make it straightforward to adopt. Caveat: maintenance is aging (last release 275 days ago) and testing is documented only through Django 4.0; verify compatibility with your Django version before committing to production.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: single runtime dependency (hashids), pure Python wheel, tested across Django 1.11 through 4.0 and Python 3.6–3.10.
- Maintenance is aging—last release 275 days ago, repository active but not frequently updated.
License · maintenance · safety
MIT (permissive) — MIT license (permissive): you may use, modify, and distribute freely in commercial and private projects with minimal restrictions; include a copy of the license.
last release 2025-11-12 (275 days) · last repo commit 2025-11-12 · 46 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 75,445 downloads/mo, #14,712 on PyPI
Alternatives
Verify before relying
pip install django-hashids
from django_hashids import HashidsField
from django.db import models
class Item(models.Model):
hashid = HashidsField(real_field_name="id")
item = Item.objects.create()
print(item.hashid) # e.g., '1Z'
Item.objects.get(hashid="1Z")- Whether the package works with Django versions newer than 4.0 (tested through 4.0 only; latest release is recent but changelog not provided).
- Performance characteristics when filtering or querying on hashid fields with large datasets.
What it is and what it does
django-hashids is a Django model field that encodes and decodes primary keys as hashids—short, obfuscated strings like '1Z' or '4x'—without modifying the database schema or the underlying id field. It acts as a transparent proxy: your model's id continues to work normally, but the hashid field lets you expose non-sequential, non-guessable identifiers in URLs, APIs, and user-facing contexts. Queries and filtering work on the hashid string, and the library handles the encode/decode automatically.
The field supports Django ORM lookups (exact, iexact, contains, icontains, gt, gte, lt, lte, isnull, and __in), works with Django REST Framework serializers, integrates with Django Admin search, and can be configured globally via settings (DJANGO_HASHIDS_SALT, DJANGO_HASHIDS_MIN_LENGTH, DJANGO_HASHIDS_ALPHABET) or per-field with custom salt, length, and alphabet. It depends only on the hashids library and is designed to be non-intrusive—you add the field to your model and use it; no migrations or database changes required.
Use it for
- Expose non-sequential, non-guessable IDs in public URLs (e.g., /item/1Z/ instead of /item/1/) to avoid leaking data patterns.
- Use hashids as slug-like identifiers in REST APIs to obscure the actual database primary key from clients.
- Filter and query Django ORM by hashid string in views and querysets without manual encode/decode logic.
- Integrate hashid fields into Django Admin search_fields for exact ID lookups by the encoded string.
- Configure global or per-field hashid encoding rules (salt, minimum length, custom alphabet) for different security or readability needs.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to expose non-sequential IDs in URLs or APIs without database changes.
The low install friction, permissive license, and transparent ORM integration make it straightforward to adopt. Caveat: maintenance is aging (last release 275 days ago) and testing is documented only through Django 4.0; verify compatibility with your Django version before committing to production.
Install
django-hashids on PyPI
Before you install
Low friction: single runtime dependency (hashids), pure Python wheel, tested across Django 1.11 through 4.0 and Python 3.6–3.10. Maintenance is aging—last release 275 days ago, repository active but not frequently updated.
License in practice
MIT license (permissive): you may use, modify, and distribute freely in commercial and private projects with minimal restrictions; include a copy of the license.
Quickstart
pip install django-hashids
from django_hashids import HashidsField
from django.db import models
class Item(models.Model):
hashid = HashidsField(real_field_name="id")
item = Item.objects.create()
print(item.hashid) # e.g., '1Z'
Item.objects.get(hashid="1Z")
Verify before relying
- Whether the package works with Django versions newer than 4.0 (tested through 4.0 only; latest release is recent but changelog not provided).
- Performance characteristics when filtering or querying on hashid fields with large datasets.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release <4,>=3.6.2 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagehashids |
| Maintenance | Aging 275 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 75,445 / month, #14,712 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: django_hashids-0.7.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “django hashid field”
- django-hashidsProvides a Django model field that proxies primary keys as…
- django-hashid-fieldProvides a Django model field that obfuscates integer IDs using the…
- django-sqidsAdds a Django model field that encodes primary keys as short,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Dynamic Content packages
MarkupSafe provides a text object that escapes special characters so untrusted strings can be safely embedded in HTML and XML without injection attacks.
Jinja2 is a templating engine that renders dynamic content by combining templates with Python-like syntax and data, supporting template inheritance, macros, autoescaping, and sandboxed execution.
Soupsieve is a CSS selector library designed to work with Beautiful Soup 4 to select, match, and filter HTML and XML elements using modern CSS selectors from CSS level 1 through CSS level 4 specifications.
Install it if you use Beautiful Soup for HTML or XML parsing and want modern CSS selector support.
Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.
Flask is a lightweight WSGI web application framework for building web applications in Python, from simple single-page sites to complex multi-route applications.
Mako compiles Python-embedded templates into Python modules for fast rendering, supporting layout inheritance, custom functions, and direct Python expressions within template syntax.
See also django-hashid-field · django-sqids · hashids · sqids · shortuuid · django-picklefield · django-crum · django-cryptography · nanoid · drf-writable-nested