From c352ea7596dbab80c8dca9065a518cd1df2ea368 Mon Sep 17 00:00:00 2001 From: Wayne Witzel III Date: Mon, 21 Aug 2017 01:53:21 -0400 Subject: [PATCH] Update HostManager to return only a single matching hostname for SmartInventory filter --- awx/api/views.py | 2 +- awx/main/managers.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/api/views.py b/awx/api/views.py index ea53e4e973..c9bc76e894 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -1936,7 +1936,7 @@ class HostList(ListCreateAPIView): if filter_string: filter_qs = SmartFilter.query_from_string(filter_string) qs &= filter_qs - return qs.distinct() + return qs.order_by('pk').distinct() def list(self, *args, **kwargs): try: diff --git a/awx/main/managers.py b/awx/main/managers.py index 2deeeb7046..3614caab8c 100644 --- a/awx/main/managers.py +++ b/awx/main/managers.py @@ -42,7 +42,7 @@ class HostManager(models.Manager): # injected by the related object mapper. self.core_filters = {} qs = qs & q - return qs.distinct() + return qs.order_by('pk').distinct('name') return qs