3-Level Filter-By Example

Example Overview

This example chains three TomSelectModelChoiceField dropdowns into a hierarchical selection where each level filters on the choice made in the level above it: region, then country, then local market. Every level uses PluginDropdownHeader to present supporting metrics alongside the options. Use this pattern for any multi-tiered dependent selection, such as publishing regions down to local markets or car make >> model >> trim.

Visual Examples

Screenshot: 3-Level Filter-By


Key Code Segments

Forms

The form leverages TomSelectModelChoiceField to define hierarchical filtering.


Templates

The form fields are rendered dynamically in the template.


Autocomplete Views

Dynamic filtering logic is handled by autocomplete endpoints in the backend.


Design and Implementation Notes

Key Features

  • Dynamic Filtering: Each dropdown is filtered based on the selected value of the parent dropdown. Trying to select a country without a region will show an empty list. Likewise, trying to select a local market without a country will also show an empty list.

  • Header Customization: PluginDropdownHeader adds informative headers with columns like “Potential Readers” and “Markets.”

Design Decisions

  • Using hierarchical filtering ensures scalability for large datasets without loading all options at once.

  • Plugin configurations like extra_columns enhance the dropdown’s usability by providing rich, tabular data.