django-selectable-select2 icondjango-selectable-select2 0.2.2

Plugin for django-selectable (to use with select2 UI)
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.

last updated on:
September 21st, 2012, 13:41 GMT
price:
FREE!
developed by:
Slawek Ehlert
license type:
BSD License 
category:
ROOT \ Internet \ HTTP (WWW)

FREE!

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Add your review!

SUBMIT