Skip to main content

django-searchable-select

https://travis-ci.org/and3rson/django-searchable-select.svg
https://coveralls.io/repos/github/and3rson/django-searchable-select/badge.svg

A better and faster multiple selection widget with suggestions for Django

What is this?

This plugin provides a replacement for standard multi-choice select on Django admin pages.

You can use this as custom widget for ManyToManyField.

Features

  • Filtering is performed on server side and thus significantly improves performance.

  • Uses Twitter Typeahead to provide suggestion completion.

  • Works great with ManyToMany fields that can be chosen from thousands of thousands of choices, e. g. User - City relations.

Before

Before

Before

After

Before

Before

Installation

  1. Install django-searchable-select.

    $ pip install django-searchable-select
  2. Add ‘searchableselect’ to your settings.

    # settings.py
    
    INSTALLED_APPS = (
        # ...
        'searchableselect',
        # ...
    )
  3. Add URL pattern required for the suggesting engine to your root urls.py.

    # urls.py
    
    urlpatterns = patterns(
        '',
        # ...
        url('^searchableselect/', include('searchableselect.urls')),
        # ...
    )
  4. Use the widget in your model admin class:

    from django import models, forms
    from searchableselect.widgets import SearchableSelect
    from models import Traveler
    
    class TravelerForm(forms.ModelForm):
        class Meta:
            model = Traveler
            exclude = ()
            widgets = {
                'cities_visited': SearchableSelect(model='cities.City', search_field='name', limit=10)
            }
    
    
    class TravelerAdmin(admin.ModelAdmin):
        form = TravelerForm
    
    admin.site.register(Traveler, TravelerAdmin)

    Remember to always initialize SearchableSelect with three keyword arguments: model, search_field and many.

    • model is the string in form APP_NAME.MODEL_NAME representing your model in the project, e. g. ‘cities.City’

    • search_field is the field within model that will be used to perform filtering, e. g. ‘name’

    • many must be True for ManyToManyField and False for ForeignKey.

    • limit (optional) specifies the maximum count of entries to retrieve. Defaults to 10.

Example app

Just run the project from example directory, head to http://127.0.0.1:8000, login as admin/admin and try adding Cats!

Supported versions

  • Python 2.7.x: Django 1.7, 1.8, 1.9, 1.10

  • Python 3.x: Django 1.8, 1.9, 1.10, 2.0

Known issues

  • Not tested with empty fields.

Contributing

I’m looking forward to bug reports and any kind of contribution.

License

You are free to use this where you want as long as you keep the author reference. Please see LICENSE for more info.

Metadata

Release files for django-searchable-select 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-searchable-select 1.5.0
File Size Uploaded
django-searchable-select-1.5.0.tar.gz 61.8 kB Details

Release files / django-searchable-select-1.5.0.tar.gz

Download URL django-searchable-select-1.5.0.tar.gz
Size 61.8 kB
Tags Source
SHA-256 checksum
How to use checksums
51f0695adf3769f12992ca5baf7818ad7033f9783c87cffca384d22d51e4bc4e
BLAKE2b-256 checksum
How to use checksums
e961351c78d5ac0c18164657df0a4569ceb1a70ed0bdc7f72761816929742a04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.5.0 This release

1 release file

1.4.5

1 release file

1.4.4

1 release file

1.4.3

1 release file

1.4.2

1 release file

1.4.1

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page