Fix: correctly extract all ids for nested tags (#11888)

This commit is contained in:
shamoon
2026-01-26 09:12:03 -08:00
committed by GitHub
parent 2312314aa7
commit 891f4a2faf
3 changed files with 23 additions and 4 deletions

View File

@@ -467,11 +467,11 @@ class TagViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
if descendant_pks:
filter_q = self.get_document_count_filter()
children_source = (
children_source = list(
Tag.objects.filter(pk__in=descendant_pks | {t.pk for t in all_tags})
.select_related("owner")
.annotate(document_count=Count("documents", filter=filter_q))
.order_by(*ordering)
.order_by(*ordering),
)
else:
children_source = all_tags
@@ -483,7 +483,11 @@ class TagViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
page = self.paginate_queryset(queryset)
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
response = self.get_paginated_response(serializer.data)
if descendant_pks:
# Include children in the "all" field, if needed
response.data["all"] = [tag.pk for tag in children_source]
return response
def perform_update(self, serializer):
old_parent = self.get_object().get_parent()