mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-06 06:38:03 -05:00
prefetch food relations #1965
This commit is contained in:
@@ -527,9 +527,10 @@ class FoodViewSet(viewsets.ModelViewSet, TreeMixin):
|
|||||||
shopping_status = ShoppingListEntry.objects.filter(space=self.request.space, food=OuterRef('id'),
|
shopping_status = ShoppingListEntry.objects.filter(space=self.request.space, food=OuterRef('id'),
|
||||||
checked=False).values('id')
|
checked=False).values('id')
|
||||||
# onhand_status = self.queryset.annotate(onhand_status=Exists(onhand_users_set__in=[shared_users]))
|
# onhand_status = self.queryset.annotate(onhand_status=Exists(onhand_users_set__in=[shared_users]))
|
||||||
return self.queryset.annotate(shopping_status=Exists(shopping_status)).prefetch_related('onhand_users',
|
return self.queryset\
|
||||||
'inherit_fields').select_related(
|
.annotate(shopping_status=Exists(shopping_status))\
|
||||||
'recipe', 'supermarket_category')
|
.prefetch_related('onhand_users', 'inherit_fields', 'child_inherit_fields', 'substitute')\
|
||||||
|
.select_related('recipe', 'supermarket_category')
|
||||||
|
|
||||||
@decorators.action(detail=True, methods=['PUT'], serializer_class=FoodShoppingUpdateSerializer, )
|
@decorators.action(detail=True, methods=['PUT'], serializer_class=FoodShoppingUpdateSerializer, )
|
||||||
# TODO DRF only allows one action in a decorator action without overriding get_operation_id_base() this should be PUT and DELETE probably
|
# TODO DRF only allows one action in a decorator action without overriding get_operation_id_base() this should be PUT and DELETE probably
|
||||||
|
|||||||
Reference in New Issue
Block a user