https://github.com/hearthsim/django-intenumfield
An IntEnumField for Django
https://github.com/hearthsim/django-intenumfield
django enum enum34 python
Last synced: about 1 year ago
JSON representation
An IntEnumField for Django
- Host: GitHub
- URL: https://github.com/hearthsim/django-intenumfield
- Owner: HearthSim
- License: mit
- Created: 2016-11-22T18:10:04.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2023-07-05T23:28:34.000Z (almost 3 years ago)
- Last Synced: 2024-10-06T07:37:50.840Z (over 1 year ago)
- Topics: django, enum, enum34, python
- Language: Python
- Size: 42 KB
- Stars: 2
- Watchers: 8
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django IntEnumField
[](https://travis-ci.org/HearthSim/django-intenumfield)
An IntEnumField for Django.
## Features
* Store your multiple-choice options as a smallint (2 bytes) instead of varchar
* Reuse existing IntEnums as choice values
* Integrates well with Django's admin app (display and filter)
## Requirements
* Python 3.8+
* Django 2.2+
## Usage
```py
from enum import IntEnum
from django.db import models
from django_intenum import IntEnumField
class Status(IntEnum):
UNKNOWN = 0
IN_PROGRESS = 1
COMPLETED = 2
ERROR = 3
class Job(models.Model):
status = IntEnumField(enum=Status)
```
## License
This project is licensed under the MIT license. The full license text is
available in the LICENSE file.