|
|
|
|
@ -98,10 +98,10 @@ def search_city(request): |
|
|
|
|
term = request.GET.get('term') |
|
|
|
|
country = request.GET.get('country') |
|
|
|
|
if not term: |
|
|
|
|
qs = City.objects.language().filter(country=country)[:200] |
|
|
|
|
qs = City.objects.language().filter(country=country).distinct()[:200] |
|
|
|
|
else: |
|
|
|
|
qs = City.objects.language().filter(country=country, translations__name__contains=term) |
|
|
|
|
result = list(set([{'id': city.id, 'label': city.name} for city in qs])) |
|
|
|
|
qs = City.objects.language().filter(country=country, translations__name__contains=term).distinct() |
|
|
|
|
result = [{'id': city.id, 'label': city.name} for city in qs] |
|
|
|
|
return JsonResponse(json.dumps(result), content_type='application/json', safe=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|