#15961 closed New feature (fixed)
Admin search should be pluggable
Reported by: | Jeremy Dunck | Owned by: | anonymous |
---|---|---|---|
Component: | contrib.admin | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | kmike84@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description ¶
RIght now, the ModelAdmin search_fields functionality is implemented in admin.views.ChangeList.get_query_set:
http://code.djangoproject.com/browser/django/tags/releases/1.3/django/contrib/admin/views/main.py#L256
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?
Change History (21)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 14 years ago
For some additional context, I've seen search_fields queries take hours to complete, where an equivalent Solr search would be seconds.
comment:5 by , 13 years ago
Cc: | added |
---|
comment:8 by , 12 years ago
Triage Stage: | Design decision needed → Accepted |
---|
The idea doesn't seem controversial, bumping to "accepted".
comment:10 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:11 by , 12 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:12 by , 12 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:14 by , 12 years ago
Patch needs improvement: | set |
---|
Documentation needs review - there's a few typos; but the code looks good to me.
comment:17 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This is a rather important feature, and there are many questions in the initial report. I think its design should be discussed on the mailing list.