Admin search should be pluggable
|Reported by:||Jeremy Dunck||Owned by:||anonymous|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
RIght now, the ModelAdmin search_fields functionality is implemented in admin.views.ChangeList.get_query_set:
Choosing search fields often requires tough tradeoffs between utility (searching all fields that are likely useful) and performance (joining over large M2M traversals is hard on the DB).
It would be good if the implementation for search_fields were pluggable; on the current project, I wish I could use Haystack/Solr there.
What about adding a hook, .get_search_results(self, query) which would return either a queryset or a list of primary keys? The rest of ChangeList could remain unchanged, just incorporating the result into the QuerySet resulting from get_query_set.
As for declaring a backend, how about adding ModelAdmin.search_backend which is a dotted python-path string?