{"id":9670,"library":"django-enumfields","title":"django-enumfields","description":"django-enumfields provides robust integration of Python's `enum.Enum` types with Django models, forms, and REST Framework serializers. It's currently at version 2.1.1 and follows a moderate release cadence, primarily focusing on Django and Python version compatibility and bug fixes.","status":"active","version":"2.1.1","language":"python","source_language":"en","source_url":"https://github.com/hzdg/django-enumfields","tags":["django","enum","orm","models","forms","restframework"],"install":[{"cmd":"pip install django-enumfields","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core functionality is built on Django's ORM.","package":"Django","optional":false},{"reason":"Provides EnumField serializer support for DRF.","package":"djangorestframework","optional":true}],"imports":[{"wrong":"from enumfields import EnumField","symbol":"EnumField","correct":"from enumfields import EnumField"},{"symbol":"EnumIntegerField","correct":"from enumfields import EnumIntegerField"},{"symbol":"EnumFieldMixin","correct":"from enumfields import EnumFieldMixin"}],"quickstart":{"code":"import enum\nfrom django.db import models\nfrom enumfields import EnumField, EnumIntegerField, EnumCharField\n\nclass MyEnum(enum.Enum):\n    FIRST = 1\n    SECOND = 2\n    THIRD = 3\n\nclass MyCharEnum(enum.Enum):\n    FOO = 'foo'\n    BAR = 'bar'\n\nclass MyModel(models.Model):\n    # Stores the enum value as its internal integer value\n    my_int_field = EnumIntegerField(MyEnum, default=MyEnum.FIRST)\n    \n    # Stores the enum value as its internal value (can be mixed types)\n    my_field = EnumField(MyEnum, default=MyEnum.FIRST)\n    \n    # Stores the enum value as a string (requires max_length)\n    my_char_field = EnumCharField(MyCharEnum, max_length=10, default=MyCharEnum.FOO)\n\n    def __str__(self):\n        return f'{self.my_int_field.name} - {self.my_char_field.value}'\n\n# Example usage:\n# instance = MyModel.objects.create(my_int_field=MyEnum.SECOND, my_char_field=MyCharEnum.BAR)\n# print(instance.my_int_field) # MyEnum.SECOND\n# print(instance.my_int_field.value) # 2\n# print(instance.my_char_field.name) # FOO","lang":"python","description":"Define Python `enum.Enum` classes and use `EnumField`, `EnumIntegerField`, or `EnumCharField` in your Django models. The field stores the enum's value in the database and retrieves it as the enum instance."},"warnings":[{"fix":"Upgrade Python to 3.7+ and Django to 2.1+ before upgrading `django-enumfields` to 2.0.0 or later.","message":"Version 2.0.0 dropped support for Python 2.7, 3.4 and Django 1.8, 1.10. Ensure your project meets the new minimum requirements.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Upgrade Django to 2.2, 3.0, 3.1 or newer. If not possible, pin `django-enumfields<2.1.0`.","message":"Version 2.1.0 dropped support for Django 2.0 and 2.1. Projects on these Django versions must upgrade Django or stick to older `django-enumfields` versions.","severity":"breaking","affected_versions":">=2.1.0"},{"fix":"Immediately upgrade to `django-enumfields==2.1.1` or newer to fix the string conversion issue.","message":"A regression in version 2.1.0 mistakenly broke string-to-enum conversion, potentially causing `ValueError` or incorrect data when loading models or deserializing data where string values were expected.","severity":"gotcha","affected_versions":"2.1.0"},{"fix":"Always specify `max_length` when using `EnumCharField`, e.g., `EnumCharField(MyCharEnum, max_length=10)`.","message":"`EnumCharField` requires `max_length` just like a standard Django `CharField`. Forgetting it will result in `FieldError` or `SystemCheckError`.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'2.1.1':28 'bug':44 'cadenc':34 'compat':42 'current':25 'django':2,5,16,38,46 'django-enumfield':1,4 'enum':47 'enum.enum':13 'enumfield':3,6 'fix':45 'focus':36 'follow':30 'form':18,50 'framework':21 'integr':9 'model':17,49 'moder':32 'orm':48 'primarili':35 'provid':7 'python':11,40 'releas':33 'rest':20 'restframework':51 'robust':8 'serial':22 'type':14 'version':27,41","created_at":"2026-04-17T01:20:07.256598+00:00","updated_at":"2026-04-17T01:20:07.256598+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmp4qd75t4u/venv/lib/python3.12/site-packages/enumfields/__init__.py\", line 1, in <module>\n    from .enums import Enum, IntEnum\n  File \"/tmp/tmp4qd75t4u/venv/lib/python3.12/site-packages/enumfields/enums.py\", line"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.1.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/hzdg/django-enumfields","docs":null,"changelog":null,"pypi":"https://pypi.org/project/django-enumfields/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","database","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}