From eeadf7b9e409d6622461b1016ec2c4fead560811 Mon Sep 17 00:00:00 2001 From: Brian Tiemann Date: Thu, 6 Mar 2025 11:52:28 -0500 Subject: [PATCH] Add docstrings for get_queryset base class methods --- netbox/netbox/api/viewsets/__init__.py | 4 ++++ netbox/netbox/views/generic/bulk_views.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/netbox/netbox/api/viewsets/__init__.py b/netbox/netbox/api/viewsets/__init__.py index e5993828e..76fc7e0b1 100644 --- a/netbox/netbox/api/viewsets/__init__.py +++ b/netbox/netbox/api/viewsets/__init__.py @@ -122,6 +122,10 @@ class NetBoxModelViewSet( return obj def get_queryset(self): + """ + Reapply model-level ordering in case it has been lost through .annotate(). + https://code.djangoproject.com/ticket/32811 + """ qs = super().get_queryset() ordering = qs.model._meta.ordering return qs.order_by(*ordering) diff --git a/netbox/netbox/views/generic/bulk_views.py b/netbox/netbox/views/generic/bulk_views.py index 72eaf6f1a..967c0eadb 100644 --- a/netbox/netbox/views/generic/bulk_views.py +++ b/netbox/netbox/views/generic/bulk_views.py @@ -126,6 +126,10 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin): # def get_queryset(self, request): + """ + Reapply model-level ordering in case it has been lost through .annotate(). + https://code.djangoproject.com/ticket/32811 + """ qs = super().get_queryset(request) ordering = qs.model._meta.ordering return qs.order_by(*ordering)