1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(tags): the Tags page lists the tags by name and has a search box

The list counts each tag's VMs and hosts; a query with a count leaves
the model's ordering out, so the tags came in the order they were made.
With dozens of tags the page also gets the search box the other
administration lists have.
This commit is contained in:
catborise 2026-11-19 13:36:39 +03:00
parent a5d0dbfe66
commit 0a99713dda
7 changed files with 103 additions and 63 deletions

View file

@ -470,7 +470,9 @@ def tombstone_delete(request, pk):
@superuser_only
def tag_list(request):
"""The tags of VMs and hosts, with how many of each have them."""
tags = Tag.objects.annotate(vm_count=Count("instances", distinct=True), host_count=Count("computes", distinct=True))
# in name order: a query that counts leaves the model's ordering out
tags = Tag.objects.annotate(vm_count=Count("instances", distinct=True),
host_count=Count("computes", distinct=True)).order_by("name")
return render(request, "admin/tag_list.html", {"tags": list(tags)})