From f9c8d12a5173fa68372c2ef15bece25a9d0dcaa2 Mon Sep 17 00:00:00 2001 From: bctiemann Date: Thu, 6 Mar 2025 12:11:55 -0500 Subject: [PATCH] Add docstrings for get_queryset base class methods (#18832) --- 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)