mirror of
https://github.com/ansible/awx.git
synced 2026-05-18 06:47:41 -02:30
have instances be filtered by ID in case of no filtering criteria passed in
and then switch from using order by ID as a fallback for all ordering and instead just set instances ordering to ID as default to prevent OrderedManyToMany fields ordering from being interrupted.
This commit is contained in:
@@ -398,11 +398,11 @@ class OrderByBackend(BaseFilterBackend):
|
|||||||
order_by = value.split(',')
|
order_by = value.split(',')
|
||||||
else:
|
else:
|
||||||
order_by = (value,)
|
order_by = (value,)
|
||||||
if order_by is None:
|
default_order_by = self.get_default_ordering(view)
|
||||||
order_by = self.get_default_ordering(view)
|
# glue the order by and default order by together so that the default is the backup option
|
||||||
|
order_by = list(order_by or []) + list(default_order_by or [])
|
||||||
if order_by:
|
if order_by:
|
||||||
order_by = self._validate_ordering_fields(queryset.model, order_by)
|
order_by = self._validate_ordering_fields(queryset.model, order_by)
|
||||||
|
|
||||||
# Special handling of the type field for ordering. In this
|
# Special handling of the type field for ordering. In this
|
||||||
# case, we're not sorting exactly on the type field, but
|
# case, we're not sorting exactly on the type field, but
|
||||||
# given the limited number of views with multiple types,
|
# given the limited number of views with multiple types,
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ class InstanceList(ListAPIView):
|
|||||||
model = models.Instance
|
model = models.Instance
|
||||||
serializer_class = serializers.InstanceSerializer
|
serializer_class = serializers.InstanceSerializer
|
||||||
search_fields = ('hostname',)
|
search_fields = ('hostname',)
|
||||||
|
ordering = ('id',)
|
||||||
|
|
||||||
|
|
||||||
class InstanceDetail(RetrieveUpdateAPIView):
|
class InstanceDetail(RetrieveUpdateAPIView):
|
||||||
|
|||||||
Reference in New Issue
Block a user