Custom Content Display

Example Overview

This example shows how to render custom page content in response to the items a user selects in a django_tomselect field. A JavaScript change handler reads the metadata attached to the chosen option and updates surrounding markup, which is useful whenever a selection should drive richer on-page detail beyond the dropdown itself.

Visual Examples

Screenshot: Custom Option Display

Key Code Segments

Forms

The form for selecting embargo regions and timeframes uses TomSelectModelChoiceField and TomSelectChoiceField to render the dropdowns.

Templates

The template for the content embargo management page uses custom CSS classes to style additional information based on the selected region.

Autocomplete Views

The autocomplete-embargo-region endpoint provides the necessary data for the display. Here we override the hook_prepare_results method to format the response with additional fields.

Views

The view for managing embargoes processes the form data and displays a success message with the selected region and timeframe.