2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 22:06:28 +00:00

Fixes result limiting

- Required for index page
This commit is contained in:
Oliver Walters
2021-02-28 20:16:05 +11:00
parent 487794a938
commit 1239d4af16
4 changed files with 28 additions and 3 deletions

View File

@ -646,6 +646,20 @@ class PartList(generics.ListCreateAPIView):
queryset = queryset.filter(pk__in=parts_need_stock)
# Optionally limit the maximum number of returned results
# e.g. for displaying "recent part" list
max_results = params.get('max_results', None)
if max_results is not None:
try:
max_results = int(max_results)
if max_results > 0:
queryset = queryset[:max_results]
except (ValueError):
pass
return queryset
filter_backends = [