Skip to main content

Simple Enums for Django when working with choices in model fields.

Project description

# Django Enumerify #

## Installation ##

```
pip install django-enumerify
```

## Usage ##

```
#!python

# .../app/enums.py

from django.utils.translation import gettext as _

from enumerify.enum import Enum

class GroupKind(Enum):
PUBLIC = 0
PRIVATE = 1

i18n = (
_('Public'),
_('Private'),
)

# .../app/models.py

from django.db import models

from enumerify import fields

from .enums import GroupKind

class Group(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField()
description = models.TextField()
kind = fields.SelectIntegerField(blueprint=GroupKind, default=GroupKind.PUBLIC)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)

def __unicode__(self):
return u"Group: %s" % self.title

```

## Tests ##

```
#!python
$ python testapp/tests/runtests.py
```

Project details


Release history Release notifications

This version
History Node

0.5.2

History Node

0.5.1

History Node

0.5

History Node

0.4

History Node

0.3.3

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-enumerify-0.5.2.tar.gz (5.6 kB) Copy SHA256 hash SHA256 Source None Mar 27, 2018

Supported by

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