From f0e3031e830d267b3e7e11136e0f29ade1b9a7ad Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 26 Nov 2024 16:48:11 -0500 Subject: [PATCH] glamr/search: fix crash on full text search coming from certain pages Some, e.g. FilteredListView /filter/uniref100/, model-based views with SearchFormMixin where the model is not one of the blessed searchable ones, so e.g. UniRef100, that non-searchable model was passed to the search_result view giving a 404 since invalid model. The fix puts the "global search" placeholder as the model parameter in those cases. --- mibios/glamr/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mibios/glamr/views.py b/mibios/glamr/views.py index 3e10bac..84adf32 100644 --- a/mibios/glamr/views.py +++ b/mibios/glamr/views.py @@ -907,12 +907,12 @@ def get_context_data(self, **ctx): ] search_model = self.search_model or self.model - if search_model in [self.ANY_MODEL, None]: - ctx['search_model'] = None - ctx['search_model_name'] = self.ANY_MODEL_URL_PART - else: + if search_model in self.model_class.values(): ctx['search_model'] = search_model ctx['search_model_name'] = search_model._meta.model_name + else: + ctx['search_model'] = None + ctx['search_model_name'] = self.ANY_MODEL_URL_PART return ctx