django FormFields using the Chosen javascript plugin for jQuery
JavaScript CSS Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
chosen isolate statics in a chosen subfolder and upgrade README Jul 14, 2014
.gitignore
LICENSE Change LICENSE year to 2014, "The Atlantic Media Company" => Atlantic… Feb 5, 2014
MANIFEST.in Fix manifest and update for chosen 0.10.0 Jul 30, 2013
README.md isolate statics in a chosen subfolder and upgrade README Jul 14, 2014
setup.py Initial commit Jul 29, 2011

README.md

django-chosen

django-chosen is a project that makes available django FormFields that uses the Chosen javascript plugin. It was created by developers at The Atlantic.

Note that there is a select field library with even more features available at https://github.com/theatlantic/django-select2-forms. Most implementation work will go towards django-select2-forms.

Installation

The recommended way to install from source is with pip:

    pip install -e "git+https://github.com/theatlantic/django-chosen.git#egg=django-chosen"

If the source is already checked out, use setuptools:

    python setup.py develop

or, you can install from pypi:

    pip install django-chosen

Usage

django-chosen makes the following fields and widget available:

Fields:

  • ChosenChoiceField
  • ChosenModelChoiceField
  • ChosenMultipleChoiceField
  • ChosenModelMultipleChoiceField

Widgets:

  • ChosenSelect
  • ChosenSelectMultiple

The django-chosen fields can be passed an optional kwarg overlay that overrides the text which appears when no option is selected in the dropdown.

Add chosen to your INSTALLED_APPS, then, in your template, inject your form medias to get chosen css and js :

{{ form.media }}

Example

from django import forms
from chosen import forms as chosenforms

class BookForm(forms.Form):
    name = forms.CharField(max_length=100)
    quality = chosenforms.ChosenChoiceField(overlay="Select book quality...",
        choices=(('New', 'new'), ('Used', 'used')))
    authors = chosenforms.ChosenModelMultipleChoiceField(queryset=Author.objects.all())

License

The django code is licensed under the Simplified BSD License and is copyright The Atlantic Media Company. View the LICENSE file under the root directory for complete license and copyright information.

The Chosen javascript library included is licensed under the MIT License. View chosen/media/js/chosen.LICENSE.md for complete license and copyright information about the Chosen javascript library.

Chosen Javascript Documentation

Chosen is a library for making long, unwieldy select boxes more user friendly.

  • jQuery support: 1.4+
  • Prototype support: 1.7+

For documentation, usage, and examples, see Harvest's Chosen JS github

Chosen Javascript Credits