Skip to content

Commit 3ef5644

Browse files
ivirabyanjustin caratzas
authored and
justin caratzas
committed
Fixed autocomplete() method: spaces in query
1 parent 58ca4cd commit 3ef5644

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

haystack/query.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,11 @@ def autocomplete(self, **kwargs):
456456
for field_name, query in kwargs.items():
457457
for word in query.split(' '):
458458
bit = clone.query.clean(word.strip())
459-
kwargs = {
460-
field_name: bit,
461-
}
462-
query_bits.append(SQ(**kwargs))
459+
if bit:
460+
kwargs = {
461+
field_name: bit,
462+
}
463+
query_bits.append(SQ(**kwargs))
463464

464465
return clone.filter(six.moves.reduce(operator.__and__, query_bits))
465466

0 commit comments

Comments
 (0)