From 7e26321dd12c43df15f97d03c31f6eaaede6b89d Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 17 Mar 2023 13:52:07 +1100 Subject: [PATCH] Caching timeout fix for label printing --- InvenTree/label/api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/InvenTree/label/api.py b/InvenTree/label/api.py index ac35e34054..f07a8f891c 100644 --- a/InvenTree/label/api.py +++ b/InvenTree/label/api.py @@ -4,6 +4,8 @@ from django.conf import settings from django.core.exceptions import FieldError, ValidationError from django.http import HttpResponse, JsonResponse from django.urls import include, re_path +from django.utils.decorators import method_decorator +from django.views.decorators.cache import cache_page, never_cache from django_filters.rest_framework import DjangoFilterBackend from rest_framework import filters @@ -134,9 +136,15 @@ class LabelListView(LabelFilterMixin, ListAPI): ] +@method_decorator(cache_page(5), name='dispatch') class LabelPrintMixin(LabelFilterMixin): """Mixin for printing labels.""" + @method_decorator(never_cache) + def dispatch(self, *args, **kwargs): + """Prevent caching when printing report templates""" + return super().dispatch(*args, **kwargs) + def get(self, request, *args, **kwargs): """Perform a GET request against this endpoint to print labels""" return self.print(request, self.get_items())