Fix elasticsearch search backend tests broken by #5208

This commit is contained in:
Andy Babic 2019-06-17 22:17:59 +01:00 committed by GitHub
parent 98d3ef4743
commit 73e07ba10d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 12 deletions

View file

@ -439,19 +439,9 @@ class IndexView(WMABaseView):
# database backends.
pk_name = self.opts.pk.name
if hasattr(self.model, 'get_filterable_search_fields'):
# The model is indexed, so let's be careful to only add
# indexed fields to ordering where possible
filterable_fields = self.model.get_filterable_search_fields()
else:
filterable_fields = None
if not (set(ordering) & {'pk', '-pk', pk_name, '-' + pk_name}):
# ordering isn't already being applied to pk
if filterable_fields is None or 'pk' in filterable_fields:
ordering.append('-pk')
else:
ordering.append('-' + pk_name)
ordering.append('-' + pk_name)
return ordering

View file

@ -33,7 +33,7 @@ class Book(models.Model, index.Indexed):
search_fields = [
index.SearchField('title'),
index.FilterField('title'),
index.FilterField('pk'),
index.FilterField('id'),
]
def __str__(self):