Skip to main content

Django autocomplete widgets and views using Tom Select

Project description

Django TomSelect

PyPI Python versions Django versions Documentation License: MIT

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

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"]
    value_fields = ["id","full_name"]
  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, TomSelectConfig

class MyForm(forms.Form):
    person = TomSelectModelChoiceField(
        config = TomSelectConfig(
            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

Example Project

To see Django TomSelect in action, check out the Example Project. It demonstrates a variety of use cases, with 15 different implementations from basic atocompletion to advanced applications, showing how to use django-tomselect's autocomplete fields in a Django project.

Each of the examples is described in the Example Project docs.

Here are a few screenshots from the example project:

Rich Content Article Selection


Article List


Article Bulk Actions

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-2026.3.1.tar.gz (225.3 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-2026.3.1-py3-none-any.whl (256.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_tomselect-2026.3.1.tar.gz
  • Upload date:
  • Size: 225.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_tomselect-2026.3.1.tar.gz
Algorithm Hash digest
SHA256 fedfae4df706d09fa09191dd53542363cde23969852234b19205d298d8977ad0
MD5 db9f4edd3a0976b3b58c4af2fb8b08cc
BLAKE2b-256 b940454da1b9a361a306c386c5b2f49984185cfd9bbee89c92119e004ac4e1cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_tomselect-2026.3.1-py3-none-any.whl
  • Upload date:
  • Size: 256.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_tomselect-2026.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef5e6d47a2a54a024432253bbf291ec5d399d0b1cabe6c94b75d19a2d1426818
MD5 11cbf5dc4a82ed3ebbbac7740661d473
BLAKE2b-256 c8f0d9f76dafcaadda2ad2594aff04810ffafb15c8ea9c6ddfcf1dbb8e636983

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