def city_search_old(request): context = {} form = CitySearchForm(request.GET) #print form.data : careful, make sure its clean first print form.is_valid() print form.cleaned_data # state = form.cleaned_data['state'] # city = form.cleaned_data['city'] state = form.cleaned_data.get('state','Utah') city = form.cleaned_data.get('city','Orem') print "%s is a state" % state print "%s is a city" % city cities = City.objects.filter(name=city, state__name=state) context ['cities'] = cities context ['form'] = form return render (request, 'city_search.html', context)
def city_search_old(request): context = {} form = CitySearchForm(request.GET) #print form.data : careful, make sure its clean first print form.is_valid() print form.cleaned_data # state = form.cleaned_data['state'] # city = form.cleaned_data['city'] state = form.cleaned_data.get('state', 'Utah') city = form.cleaned_data.get('city', 'Orem') print "%s is a state" % state print "%s is a city" % city cities = City.objects.filter(name=city, state__name=state) context['cities'] = cities context['form'] = form return render(request, 'city_search.html', context)
def city_search_old(request): context = {} form = CitySearchForm(request.GET) print form.data print form.is_valid() print form.cleaned_data state = form.cleaned_data.get('state','Utah') city = form.cleaned_data.get('city','Orem') print "%s is a state" %(state) print "%s is a city" %(city) cities = City.objects.filter(name=city, state__name=state) context['cities']=cities context['form'] = form return render(request,'city_search.html', context)
def city_search_old(request): context = {} form = CitySearchForm(request.GET) form.data print form.is_valid() print form.cleaned_data city = form.cleaned_data.get('city', 'Orem') state = form.cleaned_data.get('state', 'Utah') cities = City.objects.filter(name=city, state__name=state) context['cities'] = cities context['form'] = form return render(request, 'city_search.html', context)
def city_search_post(request): context={} form = CitySearchForm(request.POST) context['form'] = form if request.method == 'POST': #check the method type if form.is_valid(): city = form.cleaned_data.get('city','Orem') state = form.cleaned_data.get('state', 'Utah') context['cities'] = City.objects.filter(name=city, state__name=state) return render(request,'city_search_post.html', context)
def city_search_post(request): context = {} form = CitySearchForm(request.POST) context['form'] = form if request.method == 'POST': #check the method type if form.is_valid(): city = form.cleaned_data.get('city', 'Orem') state = form.cleaned_data.get('state', 'Utah') context['cities'] = City.objects.filter(name=city, state__name=state) return render(request, 'city_search_post.html', context)
def city_search(request): context = {} form = CitySearchForm(request.GET) context['form'] = form if form.is_valid(): city = form.cleaned_data.get("city", "Orem") state = form.cleaned_data.get("state", "Utah") cities = City.objects.filter(name=city, state__name=state) context['cities'] = cities return render(request, 'city_search.html', context)
def city_search(request): context = {} form = CitySearchForm(request.GET) if form.is_valid(): state = form.cleaned_data.get('state', '') city = form.cleaned_data.get('city', '') cities = City.objects.filter(name=city, state__name=state) context['cities'] = cities context['form'] = form return render(request, 'city_search.html', context)
def city_search(request): context = {} form = CitySearchForm(request.GET) if form.is_valid(): state = form.cleaned_data.get('state', '') city = form.cleaned_data.get('city', '') cities = City.objects.filter( name=city, state__name=state) context['cities'] = cities context['form'] = form return render(request,'city_search.html', context)