mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
adding support for multiple values for search filter
This commit is contained in:
parent
af5474f9b3
commit
1ab7d436cc
|
@ -136,8 +136,13 @@ class SearchFilter(BaseFilterBackend):
|
||||||
Search terms are set by a ?search=... query parameter,
|
Search terms are set by a ?search=... query parameter,
|
||||||
and may be comma and/or whitespace delimited.
|
and may be comma and/or whitespace delimited.
|
||||||
"""
|
"""
|
||||||
params = request.query_params.get(self.search_param, '')
|
params = request.query_params.getlist(self.search_param, '')
|
||||||
return params.replace(',', ' ').split()
|
if params == '':
|
||||||
|
return []
|
||||||
|
elif len(params) == 1:
|
||||||
|
return params[0].replace(',', ' ').split()
|
||||||
|
else:
|
||||||
|
return params
|
||||||
|
|
||||||
def construct_search(self, field_name):
|
def construct_search(self, field_name):
|
||||||
if field_name.startswith('^'):
|
if field_name.startswith('^'):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user