-
Notifications
You must be signed in to change notification settings - Fork 5
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
How to exclude certain models? #21
Comments
Ah, found it. class MyAdminSite(AdminSiteSearchView, admin.AdminSite):
def match_objects(self, query, model_class, model_fields):
if model_class in [ModelOne, ModelTwo]:
return Q()
return super().match_objects(query, model_class, model_fields) And yes, this has already brought the search down to less than 2 seconds :) |
Yep - that's the way 👍 I've pondered on making this a bit simpler, maybe with an attribute on the admin class. Will be much simpler to do that once there's some implementation for #22, so will revisit then. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At the moment every model that's registered with the admin site is searched through, but I have some models that I'd like to exclude. They're not interesting to search through and it'll definitely help speed up the search.
As an aside, are there ways to speed up the search? Every query takes about 5 seconds to complete on my local machine, and it'll be slower on the production server for sure.
The text was updated successfully, but these errors were encountered: