Select2 option fields for Django
The app includes Select2 driven Django Widgets and Form Fields.
pip install django_select2
INSTALLED_APPSin your project settings.
When deploying on production server, run :-
python manage.py collectstatic
Documentation available at http://django-select2.readthedocs.org/.
More details can be found on my blog at - http://blog.applegrew.com/2012/08/django-select2/.
- Django - This is obvious.
- jQuery - This is not included in the package since it is expected that in most scenarios this would already be available.
- Memcached (python-memcached) - If you plan on running multiple python processes with
GENERATE_RANDOM_SELECT2_IDenabled, then you need to turn on
ENABLE_SELECT2_MULTI_PROCESS_SUPPORT. In that mode it is highly recommended that you use Memcached, to minimize DB hits.
testapp application. This application is used to manually test the functionalities of this package. This also serves as a good example.
You need only Django 1.4 or above to run that. It might run on older versions but that is not tested.
- Samuel Goldszmidt (@ouhouhsami) for reporting many fundamental issues with the code, because of which versions 2.0 and 2.0.1 were released.
- Finally fixed performance issue[#54](https://github.com/applegrew/django-select2/issues/54) in widgets when backing field is based on models and the field has an initial value.
- Updated Select2 to version 3.4.2. Please note, that if you need any of the Select2 locale files, then you need to download them yourself from http://ivaynberg.github.com/select2/ and add to your project.
- Tagging support added. See [Field API reference](http://django-select2.readthedocs.org/en/latest/ref_fields.html) in documentation.
- Updated Select2 to version 3.4.1. Please note, that if you need any of the Select2 locale files, then you need to download them yourself from http://ivaynberg.github.com/select2/ and add to your project.
- Address isssue[#36](https://github.com/applegrew/django-select2/issues/36) - Fix importerror under django1.6.
- Fuxed the way
setup.pyhandles unicode files while minfying them during package build.
- Address isssue[#39](https://github.com/applegrew/django-select2/issues/39) - MultipleSelect2HiddenInput.render() should use mark_safe().
- Address isssue[#45](https://github.com/applegrew/django-select2/issues/45) - MultipleSelect2HiddenInput returns bad has_changed value.
- Main version number bumped to bring your attention to the fact that the default Id generation scheme has now changed. Now Django Select2 will use hashed paths of fields to generate their Ids. The old scheme of generating random Ids are still there. You can enable that by setting
- Addressed issue[#30](https://github.com/applegrew/django-select2/issues/30).
- Merged pull request[#31](https://github.com/applegrew/django-select2/issues/31).
import_django_select2_js_csstemplate tags. Please see doc’s “Getting Started”, for more details.
- Updated Select2 to version 3.3.1.
- Added multi-process support. ([Issue#28](https://github.com/applegrew/django-select2/issues/28)).
- Addressed issue[#26](https://github.com/applegrew/django-select2/issues/26).
- Addressed issue[#24](https://github.com/applegrew/django-select2/issues/24).
- Addressed issue[#23](https://github.com/applegrew/django-select2/issues/23).
- Addressed some typos.
- Few more bugs fixed in
- Now production code will use minimized versions of js and css files.
- Codes added in
setup.pyto automate the task of minimizing js and css files, using a web service.
- Merged pull request (issue[#17](https://github.com/applegrew/django-select2/issues/17)). Which allows the user to pass some extra data to Select2 clients-side component.
- Updated License. The previous one was inadequently worded. Now this project use Apache 2.0 license.
- Manually merged changes from pull request (issue[#16](https://github.com/applegrew/django-select2/issues/16)).
- Django Select2 widgets now allow passing of any Select2 Js options. Previously it used to allow only white-listed options. Now it will block only black-listed options. For example, Light Select2 widgets won’t allow you to set
multipleoption, since it is an error to set them when Select2 Js is bound to
- Addressed enhancement issue[#12](https://github.com/applegrew/django-select2/issues/12).
- Addressed enhancement issue[#11](https://github.com/applegrew/django-select2/issues/11).
- Addressed performance issue[#8](https://github.com/applegrew/django-select2/issues/8).
- Fixed issue[#7](https://github.com/applegrew/django-select2/issues/7).
- Bumping up minor version since Select2 JS has been updated to version 3.2. It seems Select2 JS now includes new higher resolution icons for [Retina displays](http://en.wikipedia.org/wiki/Retina_Display).
- Fixed an issue in
setup.pybecause of which
templatetagsdirectory was not included in last PIP releases’ tar file.
AUTO_RENDER_SELECT2_STATICSsettings. This, when specified and set to
settings.pythen Django_Select2 widgets won’t automatically include the required scripts and stylesheets. When this setting is
True(default) then every Select2 field on the page will output
<link>tags to include the required JS and CSS files. This is convinient but will output the same JS and CSS files multiple times if there are more than one Select2 fields on the page.
django_select2_tagstemplate tags to manually include the required JS and CSS files, when
AUTO_RENDER_SELECT2_STATICSis turned off.
- Revised the design of heavy fields. The previous design didn’t quite make it easy to back heavy fields by big data sources. See
fields.HeavyChoiceFieldclass and its methods’ docs for more info.
- Updated docs.
- Some more fixes for issue[#4](https://github.com/applegrew/django-select2/issues/4).
- Updated Select2 JS to version 3.1.
- Added docs.
- Some bug fixes. See issue[#4](https://github.com/applegrew/django-select2/issues/4).
select2_optionskwarg to override its
attrswere being used for this too. This means backward compatibility has been broken here.
attrswill no longer override
optionsvalues. The major release version has been changed to 3, because of this backward incompatible change.
- Auto id registration fixes.
- Mostly major bug fixes in code and design. The changes were many, raising the possibility of backward incompatibility. However, the backward incompatibility would be subtle.
- Auto fields (sub-classes of AutoViewFieldMixin) now accepts
auto_idparameter. This can be used to provide custom id for the field. The default is ‘module.field_class_name’. Ideally only the first instance of an auto field is registered. This parameter can be used to force registration of additional instances by passing a unique value.
Copyright 2012 Nirupam Biswas
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this project except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.