
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
django-select2-rocks
Advanced tools
Light integration glue between Django <https://www.djangoproject.com/>
_ and
Select2 <http://ivaynberg.github.com/select2/>
_.
This project is inspired by Django-Select2 <http://django-select2.readthedocs.org/>
_ and
django-select2light <https://github.com/ouhouhsami/django-select2light/>
_.
Django-select2-rocks is distributed under the BSD 2-clause license.
pip install django_select2_rocks
add select2rocks
to your INSTALL_APPS
python manage.py collectstatic
will install Django Select2 Rocks JS.
Include jQuery (1.7+), Select2 JS/CSS (not provided, tested with v3.4.5) and select2rocks/select2rocks.js in your templates.
Now, you can use Select2ModelChoiceField
fields in your forms.
Django-select2-rocks provides widgets to render and initialize Select2 inputs.
The widget rendering is based on Django with a further step which adds a JS initialization for each input (on DOM ready). When a character is typed in the input field, an AJAX request is sent to the URL associated to the field.
The widget API is designed to allow you to pass any arguments you want to Select2 JS code (eg. allowClear option).
You can use various JSON views to answer to Select2 AJAX queries, and so to adjust search terms or the format of the results, it's possible to extend the default django-select2-rocks backend (see select2rocks-backends.js in testproj for an example).
The testproj project contains examples with a simple JSON view and a Django REST framework view.
.. code-block:: python
import select2rocks
class BeachForm(forms.Form): beach = select2rocks.Select2ModelChoiceField( queryset=Beach.objects.all(), widget=select2rocks.AjaxSelect2Widget(url_name='json_beaches'))
Beware, the internal representation of the fields uses commas (,
) to separate items. Thus you cannot use commas
in your labels. Otherwise we'll interpret it as a separator and try to work with the text on both sides of the comma,
which will most likely break.
Django-select2-rocks is developed on GitHub:
https://github.com/polyconseil/django-select2-rocks
You can either clone the public repository:
.. code-block:: bash
$ git clone git://github.com/polyconseil/django-select2-rocks.git
Once you have a copy of the source, you can install it with:
.. code-block:: bash
$ python setup.py install
FAQs
A Django application to provide AJAX autocomplete with Select2.
We found that django-select2-rocks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.