Skip to content

NetBox v4.3.5 - QuickFix - QuerySetNotOrdered in API viewsets #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Kani999
Copy link

@Kani999 Kani999 commented Aug 4, 2025


This is only a quick fix for using the API in NetBox 4.3.5 and above.
The correct solution should be to set the ordering attribute in the class Meta: of the model.

- Added explicit `.order_by('-pk')` to all queryset definitions in API viewsets to resolve QuerySetNotOrdered errors in API calls.
- Ensures consistent and predictable ordering for all NetBoxModelViewSet
- Due to netbox-community/netbox#18900
@cruse1977
Copy link
Member

good spot @Kani999 - thanks, but I think I'm going to put ordering on models instead as a fuller fix - will make sure credit is given for highlighting this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants