Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-choices

How to install django-choices

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-choices
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.1.9
1.1.12Never BuiltWhy not?
1.1.9 Available View build log
1.1.8 Available View build log
1.1.7 Available View build log
1.1.6 Available View build log
1.1.2 Available View build log
1.1.0 Failed View build log
1.0.5 Failed View build log
1.0.0 Failed View build log
Windows (64-bit)
1.1.9
1.1.12Never BuiltWhy not?
1.1.9 Available View build log
1.1.8 Available View build log
1.1.7 Available View build log
1.1.6 Available View build log
1.1.2 Available View build log
1.1.0 Failed View build log
1.0.5 Failed View build log
1.0.0 Failed View build log
Mac OS X (10.5+)
1.1.12 Available View build log
1.1.9 Available View build log
1.1.8 Available View build log
1.1.7 Available View build log
1.1.6 Available View build log
1.1.2 Available View build log
1.1.0 Failed View build log
1.0.5 Failed View build log
1.0.0 Failed View build log
Linux (32-bit)
1.1.12 Available View build log
1.1.9 Available View build log
1.1.8 Available View build log
1.1.7 Available View build log
1.1.6 Available View build log
1.1.2 Available View build log
1.1.0 Failed View build log
1.0.5 Failed View build log
1.0.0 Failed View build log
Linux (64-bit)
1.1.12 Available View build log
1.1.9 Available View build log
1.1.8 Available View build log
1.1.7 Available View build log
1.1.6 Available View build log
1.1.2 Available View build log
1.1.0 Failed View build log
1.0.5 Failed View build log
1.0.0 Failed View build log
 
Author
License
MIT
Dependencies
Lastest release
version 1.1.12 on Jun 30th, 2013
https://secure.travis-ci.org/bigjason/django-choices.png?branch=master

Order and sanity for django model choices.

Documentation is a work in progress.

Django choices provides a declarative way of using the choices option on django fields.

Installation

You can install via PyPi or direct from the github repo.

To install with pip:

$ pip install django-choices

To install with easy_install:

$ easy_install django-choices
Basic Usage

To start you create a choices class. Then you point the choices property on your fields to the choices attribute of the new class. Django will be able to use the choices and you will be able to access the values by name. For example you can replace this:

# In models.py
class Person(models.Model):
    # Choices
    PERSON_TYPE = (
        ("C", "Customer"),
        ("E", "Employee"),
        ("G", "Groundhog"),
    )
    # Fields
    name = models.CharField(max_length=32)
    type = models.CharField(max_length=1, choices=PERSON_TYPE)

With this:

# In models.py
from djchoices import DjangoChoices, ChoiceItem

class Person(models.Model):
    # Choices
    class PersonType(DjangoChoices):
        Customer = ChoiceItem("C")
        Employee = ChoiceItem("E")
        Groundhog = ChoiceItem("G")
    # Fields
    name = models.CharField(max_length=32)
    type = models.CharField(max_length=1, choices=PersonType.choices)

You can use this elsewhere like this:

# Other code
Person.create(name="Phil", type=Person.PersonType.Groundhog)

The DjangoChoices classes can be located anywhere you want. If I have a lot of declarations I will sometimes place them in a const.py or choices.py.

License

Licensed under the MIT License.

Souce Code

The source code can be found on github.

Subscribe to package updates

Last updated Jun 30th, 2013

Download Stats

Last month:6

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.