Skip to content

eivindkopperud/django-enumchoicefield-fork

 
 

Repository files navigation

Django EnumChoiceField - The fork

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%