List and Create Articles

Example Overview

This comprehensive example wires django_tomselect into a full article workflow. The list view filters articles by edition year and word count using iterable-backed fields, while the create/update form manages relationships to magazines, editions, authors, and categories with model-backed fields, plugins, and filter_by/exclude_by dependencies. Reach for this pattern when you need a realistic, feature-rich form alongside dynamic list filtering.

Visual Examples

Screenshot: Article List Screenshot: Article Update 1 Screenshot: Article Update 2


Key Code Segments

Forms

List Articles Filters

The filtering form utilizes TomSelectChoiceField for selecting year and word count ranges.

Create Article Form

The “Create Article” form employs TomSelectModelChoiceField and TomSelectModelMultipleChoiceField to manage relationships like authors, categories, and more.


Templates

List Articles

The filter form and article list are rendered in the template with built-in styling and dynamic updates.

Articles Form Template

The form is displayed using Bootstrap styling and django_tomselect integrations. Here, we manually laid out the form, but you can use django-crispy-forms or other form libraries for more automation.


Autocomplete Views

Multiple autocomplete views are used to populate the dropdowns with dynamic data, such as categories, authors, and article statuses. Please see the example app’s Autocomplete Views Code for more details.


Views

List Articles

Dynamic filters retrieve data using autocomplete endpoints.

Create / Update Article

The form is rendered with dynamic fields based on the article instance.


Implementation Notes

  • Using plugin_dropdown_header enhances the dropdown with contextual information (e.g., article count for authors).

  • plugin_dropdown_footer allows quick navigation to related views, like creating new magazines.