django-choices-field
Django field that set/get django's new TextChoices/IntegerChoices enum.
What it is and what it does
django-choices-field bridges Django's TextChoices and IntegerChoices enums with model fields, so that when you retrieve a field value from the database, you get back the actual enum member rather than its raw string or integer value. This preserves type information and lets you use enum methods and comparisons naturally in your code.
The package provides three field types: TextChoicesField for text-based choices, IntegerChoicesField for integer-based choices, and IntegerChoicesFlagField for bitwise-combinable flags. It depends only on django and typing_extensions, making it a lightweight addition to existing Django projects. The library supports modern Django versions (4.2 through 6.0) and Python 3.10 and later.
Use it for:
- Store status or state values in a model while maintaining type safety and IDE autocomplete for enum members.
- Replace raw string/integer constants in database fields with strongly-typed enum choices that can be validated at the type-checking level.
- Combine multiple flag options in a single integer field using IntegerChoicesFlagField for efficient bitwise storage.
- Simplify conditional logic by comparing model field values directly against enum members instead of string literals.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Django model fields that store and retrieve Django's TextChoices and IntegerChoices enums as native enum instances rather than raw strings or integers.
Yes. The package is actively maintained, has no known vulnerabilities, supports current Django and Python versions, and solves a genuine friction point in Django development—the gap between TextChoices/IntegerChoices enums and what you actually get back from the database. Low install friction and permissive licensing make it a straightforward addition to any Django project.
Install
django-choices-field on PyPI
pip
pip install django-choices-fielduv
uv add django-choices-fieldpoetry
poetry add django-choices-fieldInstalling django-choices-field
Before you install
Low friction install with only django and typing_extensions as runtime dependencies. Actively maintained with recent commits; supports Django 4.2 through 6.0 and Python 3.10 through 3.14.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute this package freely provided you retain the license notice.
Quickstart
pip install django-choices-field
from django.db import models
from django_choices_field import TextChoicesField
class MyModel(models.Model):
class Status(models.TextChoices):
ACTIVE = "active", "Active"
INACTIVE = "inactive", "Inactive"
status = TextChoicesField(choices_enum=Status, default=Status.ACTIVE)
obj = MyModel()
assert isinstance(obj.status, MyModel.Status)
assert obj.status == "active"
IntegerChoicesFlag requires Python 3.11 or later; base functionality requires Python 3.10+.
Verify before relying
- Whether IntegerChoicesFlagField is available in version 4.0.0 or requires a newer release.
- Performance characteristics when storing/retrieving large numbers of enum choices.
- Compatibility with Django ORM querysets (filtering, aggregation) on enum fields.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — django, typing_extensions |
| Maintenance | actively maintained — 230 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 99,312/month — #13,028 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_choices_field-4.0.0-py3-none-any.whl
Keywords: django, enum
Tags
More Application Frameworks packages
FastAPI 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
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
django-enumProvides a Django model field type that stores…
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
django-colorfieldAdds a color field to Django models with an…
permissive · top 5,000 on PyPI
parse-typeExtends the parse module with type converters…
permissive · top 5,000 on PyPI
django-deprecate-fieldsProvides a decorator to mark Django model…
permissive · top 5,000 on PyPI
django-autocomplete-lightProvides autocomplete widgets for Django forms…
permissive · top 15,000 on PyPI
jsonfieldA Django model field that stores and retrieves…
permissive · top 5,000 on PyPI
ordered-enumAdds comparison operators to Python enums so…
unclear · top 15,000 on PyPI
django-countriesProvides a Django model field for storing…
permissive · top 5,000 on PyPI