skillfed

django-bitfield

BitField in Django

django-bitfield v2.4.0 216.8K downloads/30d#9,371 on PyPI383
License unclear Active released

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

uv

uv add django-bitfield

poetry

poetry add django-bitfield

Installing 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

Framework :: DjangoIntended Audience :: DevelopersIntended Audience :: System AdministratorsOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development

Tags

django bitfield flagsdjango boolean flags databasedjango bigintegerfield flagsdjango admin checkbox flagsdjango bit operations model field
django-ormdatabase-optimizationflags-permissions

More Software Development packages

typing-extensions

Provides backported and experimental type hints…

permissive · top 100 on PyPI

numpy

NumPy provides an N-dimensional array object…

permissive · top 100 on PyPI

fastapi

FastAPI is a Python web framework for building…

permissive · top 100 on PyPI

annotated-doc

Provides a way to document function parameters,…

permissive · top 100 on PyPI

typer

Typer builds command-line applications from…

permissive · top 1,000 on PyPI

distlib

Distlib provides low-level packaging utilities…

permissive · top 1,000 on PyPI

django-enumfields

Provides Django model fields that store Python…

permissive · top 15,000 on PyPI

django-multiselectfield

Adds model and form fields to Django that let…

copyleft · top 5,000 on PyPI

django-sqids

Adds a Django model field that encodes primary…

permissive · top 15,000 on PyPI

django-flags

Django-Flags provides a feature flag system for…

permissive · top 15,000 on PyPI

jsonfield

A Django model field that stores and retrieves…

permissive · top 5,000 on PyPI

djfernet

Provides Fernet symmetric encryption for Django…

permissive · top 15,000 on PyPI

django-enum

Provides a Django model field type that stores…

permissive · top 15,000 on PyPI

django-fernet-fields-v2

Provides Fernet symmetric encryption for Django…

permissive · top 5,000 on PyPI

django-pydantic-field

Provides type-safe Pydantic model schemas for…

permissive · top 5,000 on PyPI

django-better-admin-arrayfield

Provides a list-based widget for Django's…

permissive · top 15,000 on PyPI