django-selectable-select2

0.2.2 BSD License    
  UNRATED

  165 downloads

Plugin for django-selectable (to use with select2 UI)

description

download

specs

django-selectable-select2 is a kind of a plugin for django-selectable.

It provides widgets for use with a great JS library called select2 rather than jQuery UI. It also provides it's own Lookup classes for better (IMO) serialization results and limiting results (on server side).

For now there's only a basic single-valued autocomplete widget for usage on ForeignKey (or simply ModelChoiceField) fields.

Installation and usage

- install django-selectable (you can ommit the part regarding jquery-ui)

- add selectable_select2 to INSTALLED_APPS. So it look like this:

 INSTALLED_APPS = (
 ...
 'selectable',
 'selectable_select2',
 ...
 )


- define your lookup class

Warning

as for now (until issue #64 is resolved) you should inherit from selectable_select2.base.LookupBase and selectable_select2.base.ModelLookup

- in your forms you can use selectable_select2.widgets.AutoCompleteSelect2Widget like so:

 from selectable_select2.widgets import AutoCompleteSelect2Widget
 from django import forms

 from myapp.models import MyModel # example model with a ForeignKey called ``myfk``
 from myapp.lookups import MyModelLookup # the lookup defined in previous step

 class MyModelForm(forms.ModelForm):

 class Meta:
 model = MyModel
 widgets = {
 'myfk' : AutoCompleteSelect2Widget(MyModelLookup, placeholder='select related item')
 }


Check the example project for more details.
read more   
Last updated on September 21st, 2012

#django-selectable plugin #select2 UI #Django #django-selectable #select2 #UI

0 User reviews so far.

SUBMIT