Skip to main content

A Django application to provide AJAX autocomplete with Select2.

Project description

Light integration glue between Django and Select2.

This project is inspired by Django-Select2 and django-select2light.

Django-select2-rocks is distributed under the BSD 2-clause license.


  1. pip install django_select2_rocks
  2. add select2rocks to your INSTALL_APPS
  3. python collectstatic will install Django Select2 Rocks JS.
  4. Include jQuery (1.7+), Select2 JS/CSS (not provided, tested with v3.4.5) and select2rocks/select2rocks.js in your templates.
  5. 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, a Tastypie and a Django REST framework view.

import select2rocks

class BeachForm(forms.Form):
    beach = select2rocks.Select2ModelChoiceField(

Get the Code

Django-select2-rocks is developed on GitHub:

You can either clone the public repository:

$ git clone git://

Once you have a copy of the source, you can install it with:

$ python install

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-select2-rocks, version 0.4.1
Filename, size File type Python version Upload date Hashes
Filename, size django_select2_rocks-0.4.1-py2-none-any.whl (8.6 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size django-select2-rocks-0.4.1.tar.gz (6.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page