django-bitfield
BitField in Django
What it is and what it does
django-bitfield adds a BitField model field to Django that packs multiple boolean flags into a single database BigIntegerField (stored as BIGINT). Instead of creating separate boolean columns for each flag, you define them once in the field definition and then query and manipulate them using familiar Django ORM syntax—bitwise operations, filtering, and exclusion all work through the standard QuerySet API.
The package includes admin integration via a checkbox widget and list filter, making it easy to manage flags in Django's admin interface. It's designed for PostgreSQL; SQLite and MySQL have significant limitations. The field stores flags efficiently and allows you to test, set, and clear individual flags or combinations of flags using intuitive Python syntax on model instances.
Use it for:
- Store user permissions or feature flags in a single database column instead of many boolean columns
- Implement role-based access control where each role is a bit in a flags field
- Track feature toggles or configuration states for A/B testing or gradual rollouts
- Query models by multiple flag combinations efficiently using bitwise filtering
- Manage admin UI for flag-based settings using the built-in checkbox widget
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a BitField model field for Django that stores multiple boolean flags in a single database BigIntegerField, enabling efficient flag-based queries and admin UI support.
Yes, if you use PostgreSQL and need to store multiple boolean flags efficiently in Django models. The package is actively maintained, has no known vulnerabilities, and low install friction. However, verify the license before use and confirm PostgreSQL compatibility with your deployment. Not suitable for SQLite or MySQL projects.
Install
django-bitfield on PyPI
pip
pip install django-bitfielduv
uv add django-bitfieldpoetry
poetry add django-bitfieldInstalling django-bitfield
Before you install
Low friction installation with a single dependency on Django. Actively maintained as of 2026-08-02 with recent Python 3.14 support added. Repository shows 383 stars and no archived status.
License in practice
License status is unclear—no SPDX identifier or raw license text is available in the package metadata. Verify the actual license before use in proprietary or restricted contexts.
Quickstart
pip install django-bitfield
from bitfield import BitField
class MyModel(models.Model):
flags = BitField(flags=('awesome_flag', 'flaggy_foo'))
o = MyModel.objects.create(flags=0)
if o.flags.awesome_flag:
print('Flag is set')
Requires PostgreSQL; SQLite does not support save operations using Bit, and MySQL fails on most BitField queries. Django >= 1.11 required.
Verify before relying
- Exact Python version requirements (requires_python is unspecified in metadata)
- Whether the package is compatible with the latest Django LTS versions
- Performance characteristics when dealing with large numbers of flags
Package facts
| License | not declared (unclear) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — Django |
| Maintenance | actively maintained — 12 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 216,818/month — #9,371 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_bitfield-2.4.0-py2.py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
django-enumfieldsProvides Django model fields that store Python…
permissive · top 15,000 on PyPI
django-multiselectfieldAdds model and form fields to Django that let…
copyleft · top 5,000 on PyPI
django-sqidsAdds a Django model field that encodes primary…
permissive · top 15,000 on PyPI
django-flagsDjango-Flags provides a feature flag system for…
permissive · top 15,000 on PyPI
jsonfieldA Django model field that stores and retrieves…
permissive · top 5,000 on PyPI
djfernetProvides Fernet symmetric encryption for Django…
permissive · top 15,000 on PyPI
django-enumProvides a Django model field type that stores…
permissive · top 15,000 on PyPI
django-fernet-fields-v2Provides Fernet symmetric encryption for Django…
permissive · top 5,000 on PyPI
django-pydantic-fieldProvides type-safe Pydantic model schemas for…
permissive · top 5,000 on PyPI
django-better-admin-arrayfieldProvides a list-based widget for Django's…
permissive · top 15,000 on PyPI