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

Major major major (improvements for StockItem list API)

OK LISTEN UP - Lots of work went into making this speedier:

- For related detail fields (e.g. part_detail), we pre-fetch and cache the model data
- This eliminates duplicate database hits for the same model instances
- Perform all field filtering manually, rather than using the DRF 'filter_fields' concept (this seems to add a lot of overhead)
- Use query annotations to getch calculated fields rather than fetching one-at-a-time
- And finally, if the request is AJAX then return a JsonResponse which is SO FREAKING MUCH FASTER
This commit is contained in:
Oliver Walters
2020-05-02 13:46:19 +10:00
parent 44319d24e4
commit 4197e29fce
3 changed files with 134 additions and 66 deletions

View File

@ -293,10 +293,10 @@ class PartList(generics.ListCreateAPIView):
def filter_queryset(self, queryset):
"""
Perform custom filtering of the queryset
Perform custom filtering of the queryset.
We overide the DRF filter_fields here because
"""
# Perform basic filtering
queryset = super().filter_queryset(queryset)
# Filter by 'starred' parts?