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

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -