django-enum
Full and natural support for enumerations as Django model fields.
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-enumuv
uv add django-enumpoetry
poetry add django-enumInstalling 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
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
django-choices-fieldProvides Django model fields that store and…
permissive · top 15,000 on PyPI
django-enumfieldsProvides Django model fields that store Python…
permissive · top 15,000 on PyPI
marshmallow-enumProvides an Enum field type for Marshmallow…
permissive · top 5,000 on PyPI
aenumaenum provides advanced enumeration types…
permissive · top 1,000 on PyPI
enum34Provides enumeration support for older Python…
permissive · top 5,000 on PyPI
django-bitfieldProvides a BitField model field for Django that…
unclear · top 15,000 on PyPI
parse-typeExtends the parse module with type converters…
permissive · top 5,000 on PyPI
django-add-default-valueProvides a Django migration operation to set…
permissive · top 15,000 on PyPI
django-deprecate-fieldsProvides a decorator to mark Django model…
permissive · top 5,000 on PyPI
django-colorfieldAdds a color field to Django models with an…
permissive · top 5,000 on PyPI