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-1.0.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

django_enumchoicefield-1.0.0-py2.py3-none-any.whl (14.7 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for django-enumchoicefield-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d6622645005facbab19f31b77a43c4582f69cc77a1c2e6d6c226ff0c2b18218d
MD5 44c4d06d9c1d101874358997515d2ec6
BLAKE2b-256 be0ec391344f12b9e68b6793cd4e633144905b500aaaa916cb5d812e70e48188

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_enumchoicefield-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b3dee8eaf80df188804bbb6bc64ed783225b091425798f6dfb292ddb36b64d58
MD5 e24452cc0fe3ac1a671e061cdd73f5d6
BLAKE2b-256 8613b0b4b39c3a380c6d9f86cc10861f6804deb1706b3bd5983e007c25e0bbc4

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