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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-enumchoicefield-0.3.0.tar.gz
Algorithm Hash digest
SHA256 52e0afe5303bc02217002a8c859f61e61b904a4944ab926408f0a8688164b3b9
MD5 fe030b631532fa742256cfdd93b92856
BLAKE2b-256 52869d3a6c3850779c3398387b3c47d357fc916457a793abb5e4a69cd15786bb

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