Skip to main content

A choice field for Django using native Python Enums

Project description

A Django model field for native Python 3.4 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

See Django EnumChoiceField on ReadTheDocs.

Testing

To run the tests:

$ virtualenv venv
$ source venv/bin/activate
$ pip install -r requirements-dev.txt
$ tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

django_enumchoicefield-0.6.0-py2.py3-none-any.whl (11.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django_enumchoicefield-0.6.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_enumchoicefield-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 eb8a3f1656f55f08f979d9b00bd761e34ef42c30d0b8a18c430bada3fe0928c7
MD5 225c2937ee7f8df33fade2243ea58180
BLAKE2b-256 e64e59255f6e34c860ee3df56827175fd37da4f820bbe81d1f44115ac6f95a20

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page