JourneyJoker/frontend/places/views.py

13 lines
391 B
Python
Raw Normal View History

2021-04-17 06:30:26 +00:00
from django.views.generic import View
from django.http import JsonResponse
from .api import GoogleAPI
class PlacesAutocompleteView(View):
def get(self, request, *args, **kwargs):
if term := request.GET.get("term"):
api = GoogleAPI()
results = api.autocomplete(term)
else:
results = []
return JsonResponse(results, safe=False)