mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-07 10:20:57 +00:00
perf: 优化所有View默认排序规则(name)
This commit is contained in:
@@ -20,7 +20,7 @@ from .serializer import SerializerMixin
|
||||
|
||||
__all__ = [
|
||||
'CommonApiMixin', 'PaginatedResponseMixin', 'RelationMixin',
|
||||
'ExtraFilterFieldsMixin',
|
||||
'ExtraFilterFieldsMixin'
|
||||
]
|
||||
|
||||
logger = get_logger(__name__)
|
||||
@@ -198,10 +198,7 @@ class OrderingFielderFieldsMixin:
|
||||
model = self.queryset.model
|
||||
else:
|
||||
queryset = self.get_queryset()
|
||||
if isinstance(queryset, list):
|
||||
model = None
|
||||
else:
|
||||
model = queryset.model
|
||||
model = None if isinstance(queryset, list) else queryset.model
|
||||
|
||||
if not model:
|
||||
return []
|
||||
@@ -226,11 +223,3 @@ class CommonApiMixin(
|
||||
def is_swagger_request(self):
|
||||
return getattr(self, 'swagger_fake_view', False) or \
|
||||
getattr(self, 'raw_action', '') == 'metadata'
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
|
||||
if 'name' in self.ordering_fields:
|
||||
self.ordering = ('name',)
|
||||
|
||||
return queryset
|
||||
|
Reference in New Issue
Block a user