Django REST Framework extensions

GitHub:https://github.com/chibisov/drf-extensions

官方文档:http://chibisov.github.io/drf-extensions/docs/

安装

pip install drf-extensions

 

cache用法

1、使用

from myapps.serializers import UserSerializer
from rest_framework_extensions.cache.mixins import CacheResponseMixin

class UserViewSet(CacheResponseMixin, viewsets.ModelViewSet):
    serializer_class = UserSerializer

2、设置过期时间,配置在settings.py

REST_FRAMEWORK_EXTENSIONS = {
    'DEFAULT_CACHE_RESPONSE_TIMEOUT': 5
}

 

posted @ 2017-10-19 09:43  shhnwangjian  阅读(1273)  评论(0编辑  收藏  举报