python - How to enable @cache_page for some of the Django Rest Framework views? -
i have basic rest framework setup:
url(r'^items/$', itemlist.as_view(), name='item-list'), ... class itemlist(generics.listcreateapiview): model = item serializer_class = itemserializer
i want cache request using @cache_page
decorator. tried stupid like:
url(r'^items/$', cached_items, name='item-list'), ... @cache_page(1000) def cached_items(request): return itemlist.as_view()
which doesn't work. how can wrap views properly?
with same decorator can use in url patterns class view simple view (using .as_view
method)
from django.views.decorators.cache import cache_page urlpatterns = ('', url(r'^items/$', cache_page(60 * 60)(itemlist.as_view()), name='item-list') )
Comments
Post a Comment