cache_page with Class Based Views

前端 未结 8 1945
孤独总比滥情好
孤独总比滥情好 2020-12-14 06:23

I\'m trying to do cache_page with class based views (TemplateView) and i\'m not able to. I followed instructions here:

Django--URL Caching Failing for Class Based Vi

8条回答
  •  天命终不由人
    2020-12-14 07:17

    You can add it as a class decorator and even add multiple using a list:

    @method_decorator([vary_on_cookie, cache_page(900)], name='dispatch')
    class SomeClass(View):
       ...
    

提交回复
热议问题