Merge pull request #456 from jangsutsr/fix-7656

[3.2.2]Remove search term separators
This commit is contained in:
Aaron Tan
2017-10-05 11:22:59 -04:00
committed by Matthew Jones
2 changed files with 12 additions and 9 deletions

View File

@@ -242,11 +242,10 @@ class FieldLookupBackend(BaseFilterBackend):
# Search across related objects. # Search across related objects.
if key.endswith('__search'): if key.endswith('__search'):
for value in values: for value in values:
for search_term in force_text(value).replace(',', ' ').split(): search_value, new_keys = self.value_to_python(queryset.model, key, force_text(value))
search_value, new_keys = self.value_to_python(queryset.model, key, search_term) assert isinstance(new_keys, list)
assert isinstance(new_keys, list) for new_key in new_keys:
for new_key in new_keys: search_filters.append((new_key, search_value))
search_filters.append((new_key, search_value))
continue continue
# Custom chain__ and or__ filters, mutually exclusive (both can # Custom chain__ and or__ filters, mutually exclusive (both can

View File

@@ -60,6 +60,10 @@ _Added in AWX 1.4_
?related__search=findme ?related__search=findme
Note: If you want to provide more than one search terms, please use multiple
search fields with the same key, like `?related__search=foo&related__search=bar`,
All search terms with the same key will be ORed together.
## Filtering ## Filtering
Any additional query string parameters may be used to filter the list of Any additional query string parameters may be used to filter the list of