Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/20tab/twentytab-select2
A Django widget with [Select2](http://ivaynberg.github.com/select2/) integration.
https://github.com/20tab/twentytab-select2
Last synced: 21 days ago
JSON representation
A Django widget with [Select2](http://ivaynberg.github.com/select2/) integration.
- Host: GitHub
- URL: https://github.com/20tab/twentytab-select2
- Owner: 20tab
- License: mit
- Created: 2014-02-17T16:26:11.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-03-06T18:20:06.000Z (almost 9 years ago)
- Last Synced: 2024-11-19T21:38:28.033Z (about 1 month ago)
- Language: JavaScript
- Size: 2.77 MB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
twentytab-select2
=================A Django widget with [Select2](http://ivaynberg.github.com/select2/) integration.
## Installation
Use the following command: pip install twentytab-select2
## Configuration
- Settings.py
Open settings.py and add select2 to your INSTALLED_APPS:
```py
INSTALLED_APPS = {
...,
'select2',
...
}```
twentytab-select2 will set his own jquery plugin. If you already use yours you have to define the following parameters in your settings:
```py
STATIC_URL = u'/static/'
JQUERY_LIB = 'path_to_jquery'
SELECT2_LIB = 'path_to_select2_js'
SELECT2_CSS_LIB = 'path_to_select2_css'```
- Static filesRun collectstatic command or map static directory.
## Usage
- forms.py
```py
from testapp.models import ModelTest
from django import forms
from select2.widgets import SelectAutocomplete, SelectMultipleAutocompleteclass TestForm(forms.ModelForm):
class Meta:
model = ModelTest
widgets = {
'myfield': SelectAutocomplete(),
'mymultiplefield': SelectMultipleAutocomplete(),
}```
Both widgets take a parameter called "plugin_options". It's a dictionary and it can take all select2 options.