Skip to main content
Help us improve Python packaging – donate today!

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
        )

Release history Release notifications

This version
History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-enums-0.1.9.linux-x86_64.tar.gz (12.3 kB) Copy SHA256 hash SHA256 Source None Feb 20, 2017
django_enums-0.1.9-py2.7.egg (23.1 kB) Copy SHA256 hash SHA256 Egg 2.7 Feb 20, 2017
django_enums-0.1.9-py2-none-any.whl (18.7 kB) Copy SHA256 hash SHA256 Wheel py2 Feb 20, 2017

Supported by

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