--- id: django-choices-field version: "4.0.0" license: MIT license_treatment: permissive maintenance: active --- # django-choices-field — Django field that set/get django's new TextChoices/IntegerChoices enum. License: permissive · Maintenance: active · Downloads: 99.3K/mo ## 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 above — 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 pip install django-choices-field uv add django-choices-field poetry add django-choices-field ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 99.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django enum field, django choices field, django textchoices field, django integerchoices, django model enum, django choice enum storage, django enum model field, django-orm, type-safety, enum-field [View on SkillFed](https://skillfed.io/packages/django-choices-field) · [View on PyPI](https://pypi.org/project/django-choices-field/)