Skip to main content

A choice field for Django using native Python Enums

Project description

A Django model field for native Python Enums.

Warning

TL;DR - Think twice before using this package. This is an ad hoc fork of the unmaintained Django EnumChoiceField that can be used by projects that are dependant on the said package. For new projects (or projects that look for a better way to handle enums) you are strongly advised to check out the maintained Django EnumFields.

A quick how-to

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-fork-2.1.1.tar.gz (10.4 kB view details)

Uploaded Source

File details

Details for the file django-enumchoicefield-fork-2.1.1.tar.gz.

File metadata

  • Download URL: django-enumchoicefield-fork-2.1.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for django-enumchoicefield-fork-2.1.1.tar.gz
Algorithm Hash digest
SHA256 49f00e4688bc984454d63f56942ed426acf2f4c96b75716fe3f62972554e2fd7
MD5 3d5060ccaa796136d7ac8d3651997b8c
BLAKE2b-256 8bc1534ff74e585cd952c3eb6d6777af1ffc1c427ffc4d6936ca5a569495f705

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page