Skip to main content

Django autocomplete widgets and views using Tom Select

Reason this release was yanked:

Missing files

Project description

Django TomSelect

A powerful, lightweight Django package for dynamic select inputs with autocomplete, tagging, and more.

PyPI version License

Django TomSelect integrates Tom Select into your Django projects, providing beautiful and intuitive select inputs with features like:

  • Live Search & Autocomplete

    • Real-time filtering and highlighting as you type
    • Server-side search with customizable lookups
    • Automatic pagination for large datasets
    • Customizable minimum query length
  • Rich UI Options

    • Single and multiple selection modes
    • Tabular display with custom columns
    • Bootstrap 4/5 theming support
    • Clear/remove buttons
    • Dropdown headers & footers
    • Checkbox options
    • Customizable templates

Tom Select With Single Select Tom Select Tabular With Multiple Select

Quick Start

  1. Install the package:
pip install django-tomselect
  1. Update settings.py:
INSTALLED_APPS = [
    ...
    "django_tomselect"
]

MIDDLEWARE = [
    ...
    "django_tomselect.middleware.TomSelectMiddleware",
    ...
]

TEMPLATES = [
    {
        "OPTIONS": {
            "context_processors": [
                ...
                "django_tomselect.context_processors.tomselect",
                ...
            ],
        },
    },
]
  1. Create an autocomplete view:
from django_tomselect.autocompletes import AutocompleteModelView

class PersonAutocompleteView(AutocompleteModelView):
    model = Person
    search_lookups = ["full_name__icontains"]
  1. Add URL pattern:
urlpatterns = [
    path("person-autocomplete/", PersonAutocompleteView.as_view(), name="person_autocomplete"),
]
  1. Use in your forms:
from django_tomselect.forms import TomSelectModelChoiceField

class MyForm(forms.Form):
    person = TomSelectModelChoiceField(
        url="person_autocomplete",
        value_field="id",
        label_field="full_name",
    )
  1. Include in your template:
{{ form.media }}  {# Adds the required CSS/JS #}

{{ form }}

Other Features

Advanced Filtering

  • Dependent/chained select fields
  • Field exclusion support
  • Custom search implementations
  • Hooks for overriding functionality

Flexible Configuration

  • Support for Tom Select Plugins
  • Global settings and per-form-field configuration
  • Override any template

Security

  • Built-in permission handling
    • including django auth, custom auth, object perms

Internationalization

  • Translation support
  • Customizable messages

Documentation

Contributing

Contributions are welcome! Check out our Contributor Guide to get started.

License

This project is licensed under the MIT License - see the License file for details.

Acknowledgments

This package builds on the excellent work of Philip Becker in mizdb-tomselect, with a focus on generalization, Django templates, translations, and customization.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

django_tomselect-2024.12.1.tar.gz (90.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_tomselect-2024.12.1-py3-none-any.whl (102.1 kB view details)

Uploaded Python 3

File details

Details for the file django_tomselect-2024.12.1.tar.gz.

File metadata

File hashes

Hashes for django_tomselect-2024.12.1.tar.gz
Algorithm Hash digest
SHA256 14025231211d3f984c27314ba8a275fc0ff5a2d15f2d1a61a508348c0bd98d63
MD5 44df8ed7615737b89b1a5fede80119d2
BLAKE2b-256 1122c406a95f74acabd83799bec17e5b8b7224410575707d991d6e006c579da0

See more details on using hashes here.

File details

Details for the file django_tomselect-2024.12.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tomselect-2024.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 66a1a2fbf8e7079beeb74849342c992e1b526b46f8e7b83af95f9b5804966309
MD5 8629760efb2c0195100c8674a2cc4c11
BLAKE2b-256 9028559087cae5a92dcce777d4cd1d1920eeaed26691e35fc17aa1fb83d78b71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page