Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A Django 1.7+ model field for use with Python 3 enums.

Project Description

A Django 1.7+ model field for use with Python 3 enums.

Works with any enum whose values are integers. Subclasses the IntegerField to store the enum as integers in the database.

When creating/loading fixtures, values are serialized to dotted names, like “AnimalType.Cat” for the example below.

A decorator is needed on Python enums in order to make them work with Django migrations, which require a deconstruct() method on the enum members.

Installation:

pip install enum3field

Example:

import enum
from enum3field import EnumField, django_enum

@django_enum
class AnimalType(enum.Enum):
  Cat = 1
  Dog = 2
  Turtle = 3

class Animal(models.Model):
  animalType = EnumField(AnimalType)

Requires Python 3. Not tested with Django versions prior to 1.7 but might work.

Release History

Release History

This version
History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
enum3field-0.1.1.tar.gz (2.8 kB) Copy SHA256 Checksum SHA256 Source Dec 22, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting