from django.utils.decorators import method_decorator from django.views.decorators.cache import cache_page class ProductListAPIView(generics.ListAPIView): serializer_class = ProductSerializer @method_decorator(cache_page(60)) def dispatch(self, *args, **kwargs): return super(ProductListAPIView, self).dispatch(*args, **kwargs)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter