[update] 修改一些性能问题

This commit is contained in:
ibuler
2019-07-04 21:17:39 +08:00
parent 218e425333
commit 1472f0437f
15 changed files with 59 additions and 37 deletions

View File

@@ -28,7 +28,8 @@ class OrgModelViewSet(IDInCacheFilterMixin, ModelViewSet):
class OrgBulkModelViewSet(IDInCacheFilterMixin, BulkModelViewSet):
def get_queryset(self):
queryset = super().get_queryset().all()
if hasattr(self, 'serializer_class') and \
if hasattr(self, 'action') and self.action == 'list' and \
hasattr(self, 'serializer_class') and \
hasattr(self.serializer_class, 'setup_eager_loading'):
queryset = self.serializer_class.setup_eager_loading(queryset)
return queryset