From 70bd6492dffbdbe0e6a3b5498775fe7bda48dbb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Tue, 31 May 2022 16:43:24 +0800 Subject: [PATCH] =?UTF-8?q?city=E6=9F=A5=E8=AF=A2=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/apps/system/views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/apps/system/views.py b/server/apps/system/views.py index f068a2e..f3d8cb9 100644 --- a/server/apps/system/views.py +++ b/server/apps/system/views.py @@ -36,6 +36,8 @@ from .serializers import (CitySerializer, DictSerializer, DictTypeSerializer, Fi PositionSerializer, ProvinceSerializer, RoleSerializer, UserCreateSerializer, UserListSerializer, UserModifySerializer) +from django.utils.decorators import method_decorator +from django.views.decorators.cache import cache_page import requests import json from rest_framework.exceptions import AuthenticationFailed @@ -426,6 +428,9 @@ class ProviceViewSet(PageOrNot, ListModelMixin, GenericViewSet): search_fields = ['name'] ordering = 'id' + @method_decorator(cache_page(60*60*2)) + def list(self, request, *args, **kwargs): + return super().list(request, *args, **kwargs) class CityViewSet(PageOrNot, ListModelMixin, GenericViewSet): @@ -435,6 +440,9 @@ class CityViewSet(PageOrNot, ListModelMixin, GenericViewSet): search_fields = ['name'] ordeing = 'id' + @method_decorator(cache_page(60*60*2)) + def list(self, request, *args, **kwargs): + return super().list(request, *args, **kwargs) class FileViewSet(ModelViewSet): """