mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 01:03:11 +00:00
Changed default values of filters and prefetch_related to None
This commit is contained in:
parent
d872768baf
commit
156eb89850
2 changed files with 5 additions and 4 deletions
|
|
@ -27,7 +27,7 @@ class DBSearch(BaseSearch):
|
|||
def delete(self, obj):
|
||||
pass # Not needed
|
||||
|
||||
def search(self, query_string, model, fields=None, filters={}, prefetch_related=[]):
|
||||
def search(self, query_string, model, fields=None, filters=None, prefetch_related=None):
|
||||
# Get fields
|
||||
if fields is None:
|
||||
fields = [field.field_name for field in model.get_searchable_search_fields()]
|
||||
|
|
|
|||
|
|
@ -576,7 +576,7 @@ class ElasticSearch(BaseSearch):
|
|||
except NotFoundError:
|
||||
pass # Document doesn't exist, ignore this exception
|
||||
|
||||
def search(self, query_string, model_or_queryset, fields=None, filters={}, prefetch_related=[]):
|
||||
def search(self, query_string, model_or_queryset, fields=None, filters=None, prefetch_related=None):
|
||||
# Find model/queryset
|
||||
if isinstance(model_or_queryset, QuerySet):
|
||||
model = model_or_queryset.model
|
||||
|
|
@ -602,8 +602,9 @@ class ElasticSearch(BaseSearch):
|
|||
queryset = queryset.filter(**filters)
|
||||
|
||||
# Prefetch related
|
||||
for prefetch in prefetch_related:
|
||||
queryset = queryset.prefetch_related(prefetch)
|
||||
if prefetch_related:
|
||||
for prefetch in prefetch_related:
|
||||
queryset = queryset.prefetch_related(prefetch)
|
||||
|
||||
# Return search results
|
||||
return ElasticSearchResults(self, ElasticSearchQuery(queryset, query_string, fields=fields))
|
||||
|
|
|
|||
Loading…
Reference in a new issue