Пример #1
0
def filter_cities_by_country(request):
    """ Ajax request to filter the cities choice field """
    country = request.GET.get('country')
    cities = []
    if country != '':
        cities = find_distinct_by_country(country)

    return JsonResponse(list(cities), safe=False)
Пример #2
0
    def _get_cities(self):
        cities = find_distinct_by_country(self.data['country'])
        cities_choice_list = []
        for a_city in cities:
            city_name = a_city['city']
            cities_choice_list.append(tuple((city_name, city_name)))

        self.fields['city'].choices = add_blank(cities_choice_list)
Пример #3
0
    def _get_cities(self):
        cities = find_distinct_by_country(self.data['country'])
        cities_choice_list = []
        for a_city in cities:
            city_name = a_city['city']
            cities_choice_list.append(tuple((city_name, city_name)))

        self.fields['city'].choices = add_blank(cities_choice_list)