skillfed

django-hashid-field

A Hashids obfuscated Django Model Field

django-hashid-field v3.4.1 190.5K downloads/30d#9,906 on PyPI372
Permissive license MIT DORMANT released

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-field

uv

uv add django-hashid-field

poetry

poetry add django-hashid-field

Installing 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

Development Status :: 5 - Production/StableFramework :: DjangoFramework :: Django :: 3.2Framework :: Django :: 4.2Framework :: Django :: 5.0Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

django model field hashidsobfuscate integer ids djangohashid field django ormhide database ids djangoencode ids django models
retireddjango-orm

More Database packages

psycopg2-binary

psycopg2-binary is a PostgreSQL database…

copyleft · top 1,000 on PyPI

redis

Python client library for connecting to and…

permissive · top 1,000 on PyPI

ydb

YDB Python SDK is the official client library…

permissive · top 1,000 on PyPI

snowflake-connector-python

Connects Python applications to Snowflake data…

permissive · top 1,000 on PyPI

sqlparse

sqlparse tokenizes SQL text into a tree of…

permissive · top 1,000 on PyPI

dbt-adapters

Provides base adapter protocols and shared…

permissive · top 1,000 on PyPI

django-hashids

Provides a Django model field that proxies…

permissive · top 15,000 on PyPI

django-sqids

Adds a Django model field that encodes primary…

permissive · top 15,000 on PyPI

hashids

Generates short, unique, non-sequential hashes…

permissive · top 5,000 on PyPI

django-deprecate-fields

Provides a decorator to mark Django model…

permissive · top 5,000 on PyPI

django-fernet-encrypted-fields

Provides Django model fields that encrypt data…

unclear · top 15,000 on PyPI

django-cryptography-5

Provides encrypted model fields and…

permissive · top 15,000 on PyPI

django-cryptography

Wraps Python's cryptography library to add…

permissive · top 15,000 on PyPI

django-cryptography-django5

Encrypts and decrypts data in Django models…

permissive · top 15,000 on PyPI

drf-writable-nested

Extends Django REST Framework serializers to…

permissive · top 15,000 on PyPI

django-picklefield

Provides a Django model field that stores and…

permissive · top 5,000 on PyPI