12252 allow sorting on object in search (#12357)

* 12252 allow sorting on object in search

* 12252 code review changes
This commit is contained in:
Arthur Hanson 2023-04-27 08:26:14 -07:00 committed by GitHub
parent d39c796828
commit 9a788349a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -145,9 +145,12 @@ class CachedValueSearchBackend(SearchBackend):
) )
# Omit any results pertaining to an object the user does not have permission to view # Omit any results pertaining to an object the user does not have permission to view
return [ ret = []
r for r in results if r.object is not None for r in results:
] if r.object is not None:
r.name = str(r.object)
ret.append(r)
return ret
def cache(self, instances, indexer=None, remove_existing=True): def cache(self, instances, indexer=None, remove_existing=True):
content_type = None content_type = None

View File

@ -204,7 +204,8 @@ class SearchTable(tables.Table):
order_by="object___meta__verbose_name", order_by="object___meta__verbose_name",
) )
object = tables.Column( object = tables.Column(
linkify=True linkify=True,
order_by=('name', )
) )
field = tables.Column() field = tables.Column()
value = tables.Column() value = tables.Column()