--- id: django-enum version: "2.5.0" license: MIT license_treatment: permissive maintenance: active --- # django-enum — Full and natural support for enumerations as Django model fields. License: permissive · Maintenance: active · Downloads: 172.4K/mo ## 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 above — 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 pip install django-enum uv add django-enum 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_current - Install friction: low - Maintenance: active - Downloads: 172.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django enum field, python enum database column, django bitfield flag support, enum model field django, store python enums in django, enum choices django orm, django-orm, enum-types, bitfield [View on SkillFed](https://skillfed.io/packages/django-enum) · [View on PyPI](https://pypi.org/project/django-enum/)