[PR #18418] [MERGED] Fixes: #18406 - Make GFK scope field sortable=False on tables where it appears #15344

Closed
opened 2025-12-30 00:21:24 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/18418
Author: @bctiemann
Created: 1/16/2025
Status: Merged
Merged: 1/17/2025
Merged by: @jeremystretch

Base: mainHead: 18406-scope-field-not-orderable


📝 Commits (1)

  • 1b7e827 Make GFK scope field sortable=False on tables where it appears

📊 Changes

3 files changed (+6 additions, -3 deletions)

View changed files

📝 netbox/ipam/tables/ip.py (+2 -1)
📝 netbox/virtualization/tables/clusters.py (+2 -1)
📝 netbox/wireless/tables/wirelesslan.py (+2 -1)

📄 Description

Fixes: #18406

There is a scope field on several tables that causes a crash when it is selected for sorting:

django.core.exceptions.FieldError: Field 'scope' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.

This change disables ordering on those fields, which is consistent with the existing behavior of the scope field on VLANGroupTable. It would be more ideal to find a way to sort on this column in all such tables, but since we have precedent for just disabling it this will at least prevent crashes.


🔄 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/18418 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 1/16/2025 **Status:** ✅ Merged **Merged:** 1/17/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `main` ← **Head:** `18406-scope-field-not-orderable` --- ### 📝 Commits (1) - [`1b7e827`](https://github.com/netbox-community/netbox/commit/1b7e827c5140faedcc522aa3e5351a79ce5b8869) Make GFK scope field sortable=False on tables where it appears ### 📊 Changes **3 files changed** (+6 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `netbox/ipam/tables/ip.py` (+2 -1) 📝 `netbox/virtualization/tables/clusters.py` (+2 -1) 📝 `netbox/wireless/tables/wirelesslan.py` (+2 -1) </details> ### 📄 Description ### Fixes: #18406 There is a `scope` field on several tables that causes a crash when it is selected for sorting: `django.core.exceptions.FieldError: Field 'scope' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.` This change disables ordering on those fields, which is consistent with the existing behavior of the `scope` field on `VLANGroupTable`. It would be more ideal to find a way to sort on this column in all such tables, but since we have precedent for just disabling it this will at least prevent crashes. --- <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-30 00:21:24 +01:00
adam closed this issue 2025-12-30 00:21:24 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15344