Amadeus Ajax поиск аэропорта автозаполнение не работает python
пробовал этот код, доступный здесь https://developers.amadeus.com/blog/django-jquery-ajax-airport-search-autocomplete, чтобы добавить функциональность автозаполнения в мое приложение django, но ничего не происходит,
view.py
def origin_airport_search(request):
if request.is_ajax():
try:
data = AMADEUS.reference_data.locations.get(keyword=request.GET.get('term', None), subType=Location.ANY).data
except ResponseError as error:
messages.add_message(request, messages.ERROR, error)
return HttpResponse(get_city_airport_list(data), 'application/json')
html
<body>
{% include "nav.html" %}
<script type='text/javascript'>
$(document).ready(function () {
$("#iata").autocomplete({
source: "{% url 'airport_search'%}",
minLength: 1,
delay: 200,
});
});
</script>
<form class="form" name="Query" method="post" >
{% csrf_token %}
<div class="form-row">
<div class="form-group col-md-4">
{{ form.origin|as_crispy_field }}
</div>
<div class="form-group col-md-4">
{{ form.destination|as_crispy_field }}
</div>
</div>
<div class="d-flex align-items-center form-group col-md-6">
<button type="submit" class="btn btn-primary">NotifyMe</button>
</div>
</form>
Урлы:
urlpatterns = [
path('', home, name='home'),
path('airport_search/', origin_airport_search, name='airport_search'),
]
forms.py
origin = forms.CharField(max_length=30, label='Origin', required=True, widget=forms.TextInput(
attrs={'type': 'text', 'id': 'iata', 'name': 'origin'}))
destination = forms.CharField(max_length=30, required=True, widget=forms.TextInput(
attrs={'type': 'text', 'id': 'iata', 'name': 'destination', 'placeholder': 'destination code'}))
выполнил как указано в документации, но ничего не получается.