Skip to content
This repository has been archived by the owner. It is now read-only.

orsinium-archive/djchoices

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Django app for choices with autocomplete and good readability

Installation

For python<=3.4 install enum34:

sudo pip install enum34

Install this module:

sudo pip install -e git+https://github.com/orsinium/djchoices.git#egg=djchoices

Example

Definition:

from djchoices import Choices

class SOURCES(Choices):
    IOS = 'i', 'iOS app'
    ANDROID = 'a', 'Android app'

Usage in models:

source = models.CharField(max_length=1, choices=SOURCES.choices())

Manual usage:

SOURCES.choices()
# (('a', 'Android app'), ('i', 'iOS app'))

SOURCES.IOS
# <SOURCES.IOS: ('i', 'iOS app')>

SOURCES.IOS.verbose
# 'iOS app'

SOURCES.IOS.db
# 'i'

SOURCES.IOS.name
# 'IOS'

SOURCES.IOS.value
# ('i', 'iOS app')

SOURCES.by_db('i')
# <SOURCES.IOS: ('i', 'iOS app')>

SOURCES.by_verbose('iOS app')
# <SOURCES.IOS: ('i', 'iOS app')>

SOURCES.verbose_by_db('i')
# 'iOS app'

SOURCES.db_by_verbose('iOS app')
# 'i'

About

Good choices for Django :)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published