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.

Installation

>>> pip install django-enums

Usage

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 hashes
Filename, size django_enums-0.1.9-py2.7.egg (23.1 kB) File type Egg Python version 2.7 Upload date Hashes View hashes
Filename, size django_enums-0.1.9-py2-none-any.whl (18.7 kB) File type Wheel Python version py2 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page