skillfed

django-enum

Full and natural support for enumerations as Django model fields.

django-enum v2.5.0 172.4K downloads/30d#10,339 on PyPI110
Permissive license MIT Active released

What it is and what it does

django-enum extends Django's model layer with an EnumField that treats Python enumerations as first-class database column types. Rather than storing only the raw value (string or integer) and requiring manual conversion, EnumField automatically coerces retrieved values back to their enum type, so you work with type-safe enum instances throughout your code. It handles standard enums (TextChoices, IntegerChoices), custom Enum types, and Flag types for bitfield operations.

The package intelligently selects the smallest appropriate database column type for each enum—for example, an IntegerChoices with values 0–32767 becomes a PositiveSmallIntegerField. It integrates with Django's existing choice system, supports migrations, enforces value consistency via database check constraints, and optionally works with enum-properties for richer enumeration types with multiple symmetric properties. The library is lightweight, actively maintained, and supports modern Django (4.2–6.1) and Python (3.10–3.14) versions.

Use it for:

  • Store status or state enums in models and access them as typed enum instances rather than raw strings or integers
  • Implement permission or feature flags using IntFlag with bitfield queries to efficiently check multiple permissions at once
  • Use complex enums with enum-properties to attach rich metadata (labels, RGB values, etc.) to each enum member and query by any symmetric property
  • Replace multiple boolean columns with a single Flag enum field to reduce storage and improve query performance on large tables
  • Ensure database-level consistency of enum values using check constraints while maintaining clean, type-safe Python code

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Django model field type that stores Python enumerations (Enum, IntEnum, Flag) as database columns, automatically coercing values to their enum type on retrieval.

Yes. django-enum is actively maintained, has no known vulnerabilities, low install friction, and solves a real problem—type-safe enum storage in Django models. Use it if you want enum instances (not raw values) in your ORM, need bitfield support, or work with complex enums. The 1.x to 2.x migration is documented; review the changelog if upgrading.

Install

django-enum on PyPI

pip

pip install django-enum

uv

uv add django-enum

poetry

poetry add django-enum

Installing django-enum

Before you install

Low friction: pure Python wheel with only django as a runtime dependency. Active maintenance with a release 14 days ago and recent commits; supports Django 4.2 through 6.1 and Python 3.10–3.14.

License in practice

MIT license (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install django-enum

from django.db import models
from django_enum import EnumField

class MyModel(models.Model):
    class Status(models.TextChoices):
        ACTIVE = "A", "Active"
        INACTIVE = "I", "Inactive"
    
    status = EnumField(Status, default=Status.ACTIVE)

instance = MyModel.objects.create(status=MyModel.Status.ACTIVE)
assert instance.status == MyModel.Status.ACTIVE

Verify before relying

  • Whether enum-properties integration is optional or required for complex enum support
  • Performance characteristics of bitfield queries compared to multiple boolean columns in production workloads

Package facts

License MIT (permissive)
Python support supports the current Python release (<4.0,>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 1 — django
Maintenance actively maintained — 14 days since the last release
Last repo commit
First released
Downloads 172,356/month — #10,339 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_enum-2.5.0-py3-none-any.whl

Keywords: bitfield, bitmask, database, defines, django, enum, field, flags, mask, properties

Development Status :: 5 - Production/StableEnvironment :: ConsoleFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.2Framework :: Django :: 6.0Framework :: Django :: 6.1Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: Site ManagementTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

django enum fieldpython enum database columndjango bitfield flag supportenum model field djangostore python enums in djangoenum choices django orm
django-ormenum-typesbitfield

More Libraries packages