Rich Article Select

Example Overview

This example enriches the selection interface with a detailed, visually appealing dropdown. Each option is rendered with custom HTML - author avatars, status badges, freshness indicators, category tags, and progress bars - giving editors a comprehensive overview of each article before they select. Reach for this pattern when users need to browse and choose records based on several attributes at once.

Visual Examples

Screenshot: Rich Content Article Select Options Screenshot: Rich Content Article Select Item


Key Code Segments

Forms

The form uses a TomSelectModelChoiceField with advanced rendering configurations. The TomSelectConfig object includes custom HTML templates for rendering options and selected items, allowing detailed metadata to be displayed in the dropdown.

The option template is included as a multiline string within the render attribute of the attrs dictionary. It uses JavaScript template literals to define the structure of each option, including author avatars, status badges, category tags, and progress bars.


Templates

The field is rendered in the form with minimal configuration, and custom rendering is handled in the TomSelectConfig. A key is provided to aid in understanding the custom rendering styles.


Autocomplete Views

The autocomplete-rich-article endpoint processes user queries and retrieves rich article data. The view includes custom search logic, queryset annotations, and result formatting to provide detailed metadata for each article.


Implementation Notes

  • Preloading: The dropdown is preloaded when focused to enhance user experience. If the preload option is disabled, the dropdown will load results only after the user starts typing.