mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 23:18:03 -03: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:
parent
27dc8caabd
commit
933956eccb
@ -398,11 +398,11 @@ class OrderByBackend(BaseFilterBackend):
|
||||
order_by = value.split(',')
|
||||
else:
|
||||
order_by = (value,)
|
||||
if order_by is None:
|
||||
order_by = self.get_default_ordering(view)
|
||||
default_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:
|
||||
order_by = self._validate_ordering_fields(queryset.model, order_by)
|
||||
|
||||
# Special handling of the type field for ordering. In this
|
||||
# case, we're not sorting exactly on the type field, but
|
||||
# given the limited number of views with multiple types,
|
||||
|
||||
@ -365,6 +365,7 @@ class InstanceList(ListAPIView):
|
||||
model = models.Instance
|
||||
serializer_class = serializers.InstanceSerializer
|
||||
search_fields = ('hostname',)
|
||||
ordering = ('id',)
|
||||
|
||||
|
||||
class InstanceDetail(RetrieveUpdateAPIView):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user