added search result serializer to empty string search query
This commit is contained in:
@@ -541,7 +541,7 @@ class ProductSearchTest(TestCase):
|
|||||||
q = quote("zapatos rojos")
|
q = quote("zapatos rojos")
|
||||||
limit = 2
|
limit = 2
|
||||||
|
|
||||||
url = f"{self.endpoint}?q={q}&limit=2"
|
url = f"{self.endpoint}?q={q}&limit={limit}"
|
||||||
# send in request
|
# send in request
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ def product_search(request):
|
|||||||
return Response({"errors": {"details": "No query string to parse"}})
|
return Response({"errors": {"details": "No query string to parse"}})
|
||||||
elif q is '':
|
elif q is '':
|
||||||
# return everything
|
# return everything
|
||||||
serializer = ProductSerializer(Product.objects.all(), many=True)
|
serializer = SearchResultSerializer(Product.objects.all(), many=True)
|
||||||
products = serializer.data
|
products = serializer.data
|
||||||
# filters = extract_search_filters(products)
|
# filters = extract_search_filters(products)
|
||||||
return Response(data={"filters": [], "count": len(products), "products": products})
|
return Response(data={"filters": [], "count": len(products), "products": products})
|
||||||
|
|||||||
Reference in New Issue
Block a user