Skip to main content

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)

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

Uploaded Source

Built Distribution

django_enumchoicefield-1.1.0-py2.py3-none-any.whl (18.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-enumchoicefield-1.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.7

File hashes

Hashes for django-enumchoicefield-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6df41949a774296859fbe2a55be0caf7ef08500d1a5d2e73621e4283a7204036
MD5 57011f42b2c58f34b4cf9d335fa662fe
BLAKE2b-256 c71ec4e4d9e9acf88020cdd1af21b7fb187f5ae51c05e72d940dc27134963797

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_enumchoicefield-1.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.7

File hashes

Hashes for django_enumchoicefield-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a94c2ceb26ea0eb4bdf35b524fbd2335d27c44a43d25e7e3518943f23b2752f0
MD5 25b883948de33ae34238bd3407a9d45a
BLAKE2b-256 ab683e28a5ccb79b6508d42cf15c49294ddfd787d5529c085637f308275754b5

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