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

Uploaded Source

Built Distribution

django_enumchoicefield-2.0.0-py2.py3-none-any.whl (19.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-enumchoicefield-2.0.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1

File hashes

Hashes for django-enumchoicefield-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b9b55c9cf3e94dc2bcfe778456bb71cc6a908aa1dab6c2742335afa75764eeb7
MD5 1867a6fe2743c8737588fd663a62c4ff
BLAKE2b-256 f95d3d487021d7e4b854a8c62ff7f6565dc9e7e878a438f67328b82ce793a7db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_enumchoicefield-2.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1

File hashes

Hashes for django_enumchoicefield-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9dc7d9ea2ac1fd7749262a310708d890442ac3ffdf2a65918559262570e76d07
MD5 ba7c83f06e7561beea8095166bf868f6
BLAKE2b-256 6f9293200398ca36aafeb6a9aa2e3d113e2b72ed530157dd9edb459ee5061b86

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