Skip to content

Commit

Permalink
Fixes #1624: SearchQuerySet is instantiated at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptiste Darthenay committed Jul 5, 2018
1 parent 4910ccb commit 3c76320
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions haystack/backends/elasticsearch_backend.py
Expand Up @@ -141,6 +141,7 @@ def __init__(self, connection_alias, **connection_options):
**connection_options.get("KWARGS", {})
)
self.index_name = connection_options["INDEX_NAME"]
print(self.index_name)
self.log = logging.getLogger("haystack")
self.setup_complete = False
self.existing_mapping = {}
Expand Down
6 changes: 5 additions & 1 deletion haystack/generic_views.py
Expand Up @@ -44,7 +44,6 @@ class SearchMixin(MultipleObjectMixin, FormMixin):
template_name = "search/search.html"
load_all = True
form_class = ModelSearchForm
queryset = SearchQuerySet()
context_object_name = None
paginate_by = RESULTS_PER_PAGE
paginate_orphans = 0
Expand All @@ -54,6 +53,11 @@ class SearchMixin(MultipleObjectMixin, FormMixin):
search_field = "q"
object_list = None

def get_queryset(self):
if self.queryset is None:
self.queryset = SearchQuerySet()
return self.queryset

def get_form_kwargs(self):
"""
Returns the keyword arguments for instantiating the form.
Expand Down

0 comments on commit 3c76320

Please sign in to comment.