This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Django Utility Library is a small collection of generic functions and classes for use with Django. Other than django there are no external dependencies.

Working with CHOICES tuples

Django provides no easy way for doing lookup in CHOICES tuples other than get_FIELD_display() in a database context. For using CHOICES tuples without a database and for doing reverse lookup this library has two functions: get_choice_name and get_choice_value. Furthermore there is a function to ‘translate’ a CHOICES tuple with groups to a ‘flat’ tuple. For the following examples, these CHOICES tuples are used:

        (0, 'zero'),
        (1, 'one'),
        (2, 'two'),
        (3, 'three'),
        ('group1', (
                (0, 'zero'),
                (1, 'one'),
        ('group2', (
            (2, 'two'),
            (3, 'three'),
        ('nogroup', 'four'),


Returns the human readable name of the specified (database) value, which works on a flat CHOICES tuple as well as one with groups:

>>> import djangoutillib.utils as du
>>> du.get_choice_name(SIMPLE_CHOICES, 2)
>>> du.get_choice_name(SIMPLE_CHOICES, 5)
KeyError: 5
>>> du.get_choice_name(GROUPED_CHOICES, 3)
>>> du.get_choice_name(GROUPED_CHOICES, 'nogroup')


Returns the (database) value of the specified human readable name, which works on a flat CHOICES tuple as well as one with groups:

>>> import djangoutillib.utils as du
>>> du.get_choice_value(SIMPLE_CHOICES, 'two')
>>> du.get_choice_value(GROUPED_CHOICES, 'three')
>>> du.get_choice_value(GROUPED_CHOICES, 'four')
>>> du.get_choice_value(GROUPED_CHOICES, 'five')
KeyError: 'five'


Returns a version of grouped_choices with its groups removed:

>>> import djangoutillib.utils as du
>>> du.degroup_choices(GROUPED_CHOICES)
[(0, 'zero'), (1, 'one'), (2, 'two'), (3, 'three'), ('nogroup', 'four')]
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
djangoutillib-0.1.0.tar.gz (18.9 kB) Copy SHA256 Checksum SHA256 Source May 7, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development 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