2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-17 17:58:22 +00:00

[API] Query improvements (#11034)

* Improve prefetch fields for API

* Cache ContentType queryset for getModelsWithMixin

- Called a LOT of times for an options request
- Store the list in the session cache
- Much faster than redis - and expires after the session is complete

* Skip optional prefetch for options requests

* Custom implementation of DjangoModelPermission

- Cache the queryset against the view
- Prevents multiple hits for OPTIONS request
- Saves > 100ms on /stock/ options request
This commit is contained in:
Oliver
2025-12-17 20:20:59 +11:00
committed by GitHub
parent 145f4751c2
commit 7b181bb5ae
9 changed files with 101 additions and 22 deletions

View File

@@ -268,7 +268,11 @@ class ManufacturerPartSerializer(
source='part', many=False, read_only=True, allow_null=True
),
True,
prefetch_fields=['part'],
prefetch_fields=[
Prefetch(
'part', queryset=part.models.Part.objects.select_related('pricing_data')
)
],
)
pretty_name = enable_filter(