Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A choice field for Django using native Python Enums

Project description

https://travis-ci.org/timheap/django-enumchoicefield.svg?branch=master https://readthedocs.org/projects/django-enumchoicefield/badge/?version=latest https://badge.fury.io/py/django-enumchoicefield.svg

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)

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.

Files for django-enumchoicefield, version 2.0.0
Filename, size File type Python version Upload date Hashes
Filename, size django_enumchoicefield-2.0.0-py2.py3-none-any.whl (19.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-enumchoicefield-2.0.0.tar.gz (12.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page