--- id: django-sqids version: "0.2.2" license: MIT license_treatment: permissive maintenance: aging --- # django-sqids — Non-intrusive sqids library for Django License: permissive · Maintenance: aging · Downloads: 88.6K/mo ## What it is and what it does django-sqids is a Django model field that transparently encodes your model's primary key as a sqid—a short, URL-safe, obfuscated string—without storing anything extra in the database or altering your model schema. It acts as a proxy over the real `id` field, so queries and filtering work seamlessly: you can filter by sqid string, use it in URLs as a slug, and even search by sqid in Django Admin. The underlying integer ID remains unchanged; the sqid is computed on the fly. The package is built on the sqids library and supports customization per field (min_length, alphabet, prefix) or globally via Django settings. It integrates with Django REST Framework serializers and supports standard ORM lookups like `in`, `gt`, `gte`, `lt`, `lte`, and `isnull`. The project was forked from django-hashids to adopt the newer Sqids library, which removed the "salt" parameter; django-sqids provides a `shuffle_alphabet` helper to achieve similar per-field uniqueness. Use it for: - Expose model IDs in URLs and APIs as short, non-sequential sqid strings instead of raw integers. - Hide internal database IDs from external users while keeping queries simple and database-native. - Search and filter records by sqid in Django Admin without writing custom code. - Generate unique, obfuscated identifiers for each model or field using per-instance alphabet shuffling. - Build REST APIs that accept sqid strings in place of numeric IDs without custom serializer logic. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds a Django model field that encodes primary keys as short, obfuscated sqid strings without modifying the database or model structure. Yes, if you need to expose model IDs as obfuscated strings in URLs or APIs without database changes. The package is low-friction, well-tested across modern Django and Python versions, and has no known vulnerabilities. The aging status (401 days since last release) is not a blocker—the last commit is recent and the codebase is stable—but verify that the documented Django and Python versions match your project before committing. ## Install pip install django-sqids uv add django-sqids poetry add django-sqids ## Installing django-sqids Before you install: Low friction—single runtime dependency (sqids) and a pure-Python wheel. Actively maintained with a recent commit (2025-07-09) and tested against Django 3.2, 4.2, 5.0 and Python 3.8–3.12, though the project is aging (401 days since last release). License in practice: MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects without restriction. Quickstart: pip install django-sqids from django_sqids import SqidsField from django.db import models class Item(models.Model): sqid = SqidsField(real_field_name="id") item = Item.objects.create() item.sqid # e.g., '1Z' Item.objects.get(sqid="1Z") Requires Django 3.2 or later and Python 3.8.1 or later. Verify before relying: - Performance impact of sqid encoding/decoding on large querysets or high-throughput applications. - Compatibility with Django ORM features beyond the documented lookups (in, isnull, gt, gte, lt, lte). - Behavior when used with Django's prefetch_related or select_related optimizations. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 88.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django model field sqids, encode primary key sqid, obfuscate database ids django, sqid proxy field, django url slug sqids, hide internal ids django, django-field, id-obfuscation, url-slug [View on SkillFed](https://skillfed.io/packages/django-sqids) · [View on PyPI](https://pypi.org/project/django-sqids/)