1👍
So this is how I was able to achieve it. Really simple method:
views.py
from services import elastic_result
class ElasticView(APIView):
permission_classes=[]
def post(self, title):
_search = elastic_result(id, title)
return _search
pass
services.py
import requests
import json
def elastic_result(id, request):
requestdata = json.loads(request.body)
r = requests.post('http://localhost:9200/_search', json=requestdata)
items = r.json()
return Response(items)
urls.py
import ElasticView
url(r'^elastic/_search', ElasticView.as_view()
👤Ycon
Source:stackexchange.com