Example #1
0
def search_place(request):
    # get place name
    data_from_get = request.GET
    if data_from_get.has_key("place_name"):
        place_name = data_from_get.get("place_name")
        continents = Continent.objects(name__iexact=place_name)
        countries = Country.objects(name__iexact=place_name)
        provinces = Province.objects(name__iexact=place_name)
        cities = City.objects(name__iexact=place_name)
        places = gathering(list(continents) + list(countries) + list(provinces) + list(cities))
        return render_json({"status": SUCCESS, "places": places})
    else:
        return render_json({"status": FAIL})
def cities(province):
    cities = list(City.objects(province=province))
    return cities