[PR #20642] [MERGED] Fixes #20641: Handle viewsets with queryset=None in get_view_name() #15995

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20642
Author: @jnovinger
Created: 10/21/2025
Status: Merged
Merged: 10/23/2025
Merged by: @arthanson

Base: mainHead: 20641-fix-objectchange-browsable-api


📝 Commits (1)

  • 977b10f Fixes #20641: Handle viewsets with queryset=None in get_view_name()

📊 Changes

2 files changed (+19 additions, -2 deletions)

View changed files

📝 netbox/utilities/api.py (+1 -1)
📝 netbox/utilities/tests/test_api.py (+18 -1)

📄 Description

Fixes: #20641

The get_view_name() utility function crashed with AttributeError when called on viewsets that override get_queryset() without setting a class-level queryset attribute (e.g., ObjectChangeViewSet).

This pattern became necessary in #20089 to force re-evaluation of valid_models() on each request, ensuring ObjectChange querysets reflect current ContentType state.

Added None check to fall back to DRF's default view naming when no class-level queryset exists.


🔄 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/20642 **Author:** [@jnovinger](https://github.com/jnovinger) **Created:** 10/21/2025 **Status:** ✅ Merged **Merged:** 10/23/2025 **Merged by:** [@arthanson](https://github.com/arthanson) **Base:** `main` ← **Head:** `20641-fix-objectchange-browsable-api` --- ### 📝 Commits (1) - [`977b10f`](https://github.com/netbox-community/netbox/commit/977b10f71fb2c603370d2e5accb2c9f846e48c96) Fixes #20641: Handle viewsets with queryset=None in get_view_name() ### 📊 Changes **2 files changed** (+19 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `netbox/utilities/api.py` (+1 -1) 📝 `netbox/utilities/tests/test_api.py` (+18 -1) </details> ### 📄 Description Fixes: #20641 The get_view_name() utility function crashed with AttributeError when called on viewsets that override get_queryset() without setting a class-level queryset attribute (e.g., ObjectChangeViewSet). This pattern became necessary in #20089 to force re-evaluation of valid_models() on each request, ensuring ObjectChange querysets reflect current ContentType state. Added None check to fall back to DRF's default view naming when no class-level queryset exists. --- <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:25:13 +01:00
adam closed this issue 2025-12-30 00:25:13 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15995