Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Fix: improve performance of listing result IDs (#5195)

Antoine Libert54372b561868
diff --git a/src/paperless/views.py b/src/paperless/views.py
index 16423671a..73b383a6f 100644
--- a/src/paperless/views.py
+++ b/src/paperless/views.py
@@ -56,11 +56,7 @@ class StandardPagination(PageNumberPagination):
except Exception:
pass
else:
- for obj in self.page.paginator.object_list:
- if hasattr(obj, "id"):
- ids.append(obj.id)
- elif hasattr(obj, "fields"):
- ids.append(obj.fields()["id"])
+ ids = self.page.paginator.object_list.values_list("pk", flat=True)
return ids
def get_paginated_response_schema(self, schema):