Skip to main content

A simple Enum class and EnumField for Django models.

Project description

django-enums is a simple Enum class and EnumField for Django models. Enum class inherits Enum class in the default enum module. EnumFiled class inherits Charfield.


>>> pip install django-enums


Inherit Enum class and set it to EnumField.enum.:

from django.db import models
from django_enums import enum

class MyEnum(enum.Enum):

    __order__ = 'FOO BAR FOOBAR' # for python 2

    FOO = ('f', 'Foo')
    BAR = ('b', 'Bar')
    FOOBAR = ('fb', 'FooBar')

class MyModel(models.Model):

    enum_field = enum.EnumField(
        MyEnum, # required
        default=MyEnum.FOO, # optional

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-enums, version 0.1.9
Filename, size File type Python version Upload date Hashes
Filename, size django-enums-0.1.9.linux-x86_64.tar.gz (12.3 kB) File type Source Python version None Upload date Hashes View
Filename, size django_enums-0.1.9-py2.7.egg (23.1 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size django_enums-0.1.9-py2-none-any.whl (18.7 kB) File type Wheel Python version py2 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring 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