A Django model field for native Python Enums.
from enumchoicefield import ChoiceEnum, EnumChoiceField
class Fruit(ChoiceEnum):
apple = "Apple"
banana = "Banana"
orange = "Orange"
class Profile(models.Model):
name = models.CharField(max_length=100)
favourite_fruit = EnumChoiceField(Fruit, default=Fruit.banana)
Documentation
Testing
To run the tests:
$ virtualenv venv
$ source venv/bin/activate
$ pip install -r requirements-dev.txt
$ tox
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-enumchoicefield-3.0.1.tar.gz.
File metadata
- Download URL: django-enumchoicefield-3.0.1.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
812a19fcf750918961e907b27a5fac597eced52d0a123b88128a53a494929ea7
|
|
| MD5 |
d614097ddd224e0217b35252825ac588
|
|
| BLAKE2b-256 |
75ff1164a1d1c8afe0f2dd4f18e15e69e81d365df31a1fb58a9299871e1adbb4
|