mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-17 19:51:11 +00:00
Cleaned up database backend search method
This commit is contained in:
parent
5e76a54b2b
commit
6d21727b03
1 changed files with 3 additions and 6 deletions
|
|
@ -49,7 +49,7 @@ class DBSearch(BaseSearch):
|
|||
|
||||
# Filter by terms
|
||||
for term in terms:
|
||||
term_query = None
|
||||
term_query = models.Q()
|
||||
for field_name in fields:
|
||||
# Check if the field exists (this will filter out indexed callables)
|
||||
try:
|
||||
|
|
@ -58,11 +58,8 @@ class DBSearch(BaseSearch):
|
|||
continue
|
||||
|
||||
# Filter on this field
|
||||
field_filter = {'%s__icontains' % field_name: term}
|
||||
if term_query is None:
|
||||
term_query = models.Q(**field_filter)
|
||||
else:
|
||||
term_query |= models.Q(**field_filter)
|
||||
term_query |= models.Q(**{'%s__icontains' % field_name: term})
|
||||
|
||||
query = query.filter(term_query)
|
||||
|
||||
# Distinct
|
||||
|
|
|
|||
Loading…
Reference in a new issue