[PR #7206] [MERGED] Handle null_option in applied_filters template tag #13224

Closed
opened 2025-12-29 22:26:04 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/7206
Author: @thatmattlove
Created: 9/8/2021
Status: Merged
Merged: 9/8/2021
Merged by: @jeremystretch

Base: developHead: 7205-applied-filters


📝 Commits (6)

  • 49617a5 #7205: Handle null_option in dynamic multi-select choices field
  • 752de0d Fixes #7205: Handle null_option when getting selected form values in applied_filters template tag
  • 6a15c2a Remove invalid (for Python <3.9) type annotation
  • a9c1c89 Return cleaned null_option value as None in dynamic multi-select field
  • 45988b9 Minor cleanup for get_selected_values()
  • a39a9c9 Merge branch 'develop' into 7205-applied-filters

📊 Changes

3 files changed (+23 additions, -4 deletions)

View changed files

📝 docs/release-notes/version-3.0.md (+1 -0)
📝 netbox/utilities/forms/fields.py (+10 -0)
📝 netbox/utilities/forms/utils.py (+12 -4)

📄 Description

Fixes: #7205

  • Apply same logic from DynamicModelChoiceField.clean() to DynamicModelMultipleChoiceField field so that None is added to cleaned form data
  • More importantly, use a field's null_option for applied_filters template tag when selected. For example, if 'Global' is selected, the filter should show 'Global'. After my fix from 2a293d5 in APISelect, applied_filters is now broken when a field with a null_option is selected.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/7206 **Author:** [@thatmattlove](https://github.com/thatmattlove) **Created:** 9/8/2021 **Status:** ✅ Merged **Merged:** 9/8/2021 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `7205-applied-filters` --- ### 📝 Commits (6) - [`49617a5`](https://github.com/netbox-community/netbox/commit/49617a595de54f9407253d3c1689d196b2998149) #7205: Handle `null_option` in dynamic multi-select choices field - [`752de0d`](https://github.com/netbox-community/netbox/commit/752de0d9c0e358c018ee5a9009567243a9d64831) Fixes #7205: Handle `null_option` when getting selected form values in `applied_filters` template tag - [`6a15c2a`](https://github.com/netbox-community/netbox/commit/6a15c2ae8611c4ed9b4fa14fdf7e41ba489887e2) Remove invalid (for Python <3.9) type annotation - [`a9c1c89`](https://github.com/netbox-community/netbox/commit/a9c1c8968e21787ba4f2c9f7abb273b8746e2560) Return cleaned `null_option` value as `None` in dynamic multi-select field - [`45988b9`](https://github.com/netbox-community/netbox/commit/45988b9818e52da75e5199a2b1291012220a1a18) Minor cleanup for get_selected_values() - [`a39a9c9`](https://github.com/netbox-community/netbox/commit/a39a9c9b568379e470d4f2440548ab7f98d0f618) Merge branch 'develop' into 7205-applied-filters ### 📊 Changes **3 files changed** (+23 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/release-notes/version-3.0.md` (+1 -0) 📝 `netbox/utilities/forms/fields.py` (+10 -0) 📝 `netbox/utilities/forms/utils.py` (+12 -4) </details> ### 📄 Description ### Fixes: #7205 - Apply same logic from `DynamicModelChoiceField.clean()` to `DynamicModelMultipleChoiceField` field so that `None` is added to cleaned form data - More importantly, use a field's `null_option` for `applied_filters` template tag when selected. For example, if 'Global' is selected, the filter should show 'Global'. After my fix from 2a293d5 in APISelect, `applied_filters` is now broken when a field with a `null_option` is selected. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:26:04 +01:00
adam closed this issue 2025-12-29 22:26:05 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13224