Formas escolhidas em Django

Para garantir que todas as formas do nosso projeto Django usando o plug-in ESCOLHIDO :

Instale o plugin escolhido pelo django :

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

Adicione o aplicativo a settings.py :

INSTALLED_APPS = (
...
chosen
,
....
)

Vamos construir um formulário básico que herdará o resto de nossos formulários:

from chosen import forms as chosenforms

class ChosenModelForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ChosenModelForm, self).__init__(*args, **kwargs)
for field in self.fields:
if self.fields[field].__class__.__name__ in ['ChoiceField', 'TypedChoiceField', 'MultipleChoiceField']:
choices
= self.fields[field].choices
self.fields[field] = chosenforms.ChosenChoiceField(choices=choices)
elif self.fields[field].__class__.__name__ in ['ModelChoiceField', 'ModelMultipleChoiceField']:
queryset
= self.fields[field].queryset
self.fields[field] = chosenforms.ChosenModelChoiceField(queryset=queryset)

class FormA(ChosenModelForm):
class Meta:
model
= ModelA

class FormB(ChosenModelForm):
class Meta:
model
= ModelB

Anexe os arquivos css e javascript necessários ao modelo:

...
{% block extra_js %}
{{ block.super }}
{{ form.media }}
...
{% endblock %}

et voilà !!

fonte: http://j.mp/U5eoEw