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 Distribution

django-enumchoicefield-0.8.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

django_enumchoicefield-0.8.0-py2.py3-none-any.whl (12.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-enumchoicefield-0.8.0.tar.gz.

File metadata

File hashes

Hashes for django-enumchoicefield-0.8.0.tar.gz
Algorithm Hash digest
SHA256 683ef9dd49218d424e34de0c5be5e6f45caed9e7a23aeb5a061215d05f0542fe
MD5 818a733871a3ce35a2ce047bdca7c2b6
BLAKE2b-256 d9097da15ba792a94244d2f8c8fb64480c442f19087b37ccb358540fa4e8d9f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_enumchoicefield-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c01932a4966f1dc4c4f8d973248fdc55e1c710fab0c7e42925a5b21dbfab0a83
MD5 442f16251f2deb55807dc8a9690da791
BLAKE2b-256 fed849e11a6e1e1217f4558c172ae27e47468a5f52dd410dd00e539ac4a1fe2e

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