示例#1
0
文件: views.py 项目: dareen22/states
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)
示例#2
0
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)
示例#3
0
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)
示例#4
0
文件: views.py 项目: chefface/states
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)
示例#5
0
文件: views.py 项目: bsboos/states
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)
示例#6
0
文件: views.py 项目: bsboos/states
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)
示例#7
0
文件: views.py 项目: bsboos/states
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)
示例#8
0
文件: views.py 项目: bsboos/states
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)
示例#9
0
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)
示例#10
0
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)