Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: use the ModelAdmin's search_fields #22

Open
kevinrenskers opened this issue Mar 1, 2024 · 2 comments
Open

Idea: use the ModelAdmin's search_fields #22

kevinrenskers opened this issue Mar 1, 2024 · 2 comments

Comments

@kevinrenskers
Copy link

kevinrenskers commented Mar 1, 2024

All of my models that I want to have searchable already have a custom ModelAdmin. And all of them have a search_fields property which determines which fields I want to have searchable. It would be super nice if django-admin-site-search could stick to this as well, so that search happens in the fields that I want to be searchable, no more and no less (solving #21). This should give a performance boost by not using literally every CharField subclass, and should hopefully make searching through relations automatic as well (closing #20).

Great project by the way, the results look super slick.

@ahmedaljawahiry
Copy link
Owner

Thanks for the idea, and glad you like the project!

This is a great suggestion - it makes total sense.

The current approach is definitely "greedy", but I like that you get results out-of-the-box without much configuration. I've hesitated in adding further settings (to avoid the complexity), but this seems like an easy win.

I'll have a think about implementation and see if I can get round to it soon. Suspect it'll be an option, set at the class level, to specify the search method. Something like:

site_search_method = "model_char_fields" | "admin_search_fields" | etc.

@ahmedaljawahiry
Copy link
Owner

Just a note to say I haven't forgotten about this! Busy couple of months, but hope to get to it soon 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants