mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #4871: Specify ordering for querysets using annotate() to count related objects
This commit is contained in:
@@ -22,7 +22,7 @@ from .models import Cluster, ClusterGroup, ClusterType, VirtualMachine, VMInterf
|
||||
#
|
||||
|
||||
class ClusterTypeListView(ObjectListView):
|
||||
queryset = ClusterType.objects.annotate(cluster_count=Count('clusters'))
|
||||
queryset = ClusterType.objects.annotate(cluster_count=Count('clusters')).order_by(*ClusterType._meta.ordering)
|
||||
table = tables.ClusterTypeTable
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class ClusterTypeBulkImportView(BulkImportView):
|
||||
|
||||
|
||||
class ClusterTypeBulkDeleteView(BulkDeleteView):
|
||||
queryset = ClusterType.objects.annotate(cluster_count=Count('clusters'))
|
||||
queryset = ClusterType.objects.annotate(cluster_count=Count('clusters')).order_by(*ClusterType._meta.ordering)
|
||||
table = tables.ClusterTypeTable
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class ClusterTypeBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class ClusterGroupListView(ObjectListView):
|
||||
queryset = ClusterGroup.objects.annotate(cluster_count=Count('clusters'))
|
||||
queryset = ClusterGroup.objects.annotate(cluster_count=Count('clusters')).order_by(*ClusterGroup._meta.ordering)
|
||||
table = tables.ClusterGroupTable
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class ClusterGroupBulkImportView(BulkImportView):
|
||||
|
||||
|
||||
class ClusterGroupBulkDeleteView(BulkDeleteView):
|
||||
queryset = ClusterGroup.objects.annotate(cluster_count=Count('clusters'))
|
||||
queryset = ClusterGroup.objects.annotate(cluster_count=Count('clusters')).order_by(*ClusterGroup._meta.ordering)
|
||||
table = tables.ClusterGroupTable
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user