Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Correctly cache api responses for ingredients and their images

Roland Geider92d4d78c122a
diff --git a/wger/nutrition/api/views.py b/wger/nutrition/api/views.py
index 9472cd746..ef45f2a1f 100644
--- a/wger/nutrition/api/views.py
+++ b/wger/nutrition/api/views.py
@@ -89,6 +89,10 @@ class IngredientViewSet(viewsets.ReadOnlyModelViewSet):
'license_author',
)
+ @method_decorator(cache_page(settings.WGER_SETTINGS['EXERCISE_CACHE_TTL']))
+ def dispatch(self, request, *args, **kwargs):
+ return super().dispatch(request, *args, **kwargs)
+
@action(detail=True)
def get_values(self, request, pk):
"""
@@ -205,7 +209,7 @@ class ImageViewSet(viewsets.ReadOnlyModelViewSet):
@method_decorator(cache_page(settings.WGER_SETTINGS['EXERCISE_CACHE_TTL']))
def dispatch(self, request, *args, **kwargs):
- super().dispatch(request, *args, **kwargs)
+ return super().dispatch(request, *args, **kwargs)
class WeightUnitViewSet(viewsets.ReadOnlyModelViewSet):