Представление

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# -*- coding: utf-8 -*-
# Create your views here.
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect,Http404
from agriculture.forms import EconomyForm
from agriculture.models import Economy
def EconomySearch (request ):
if request.method == 'POST':
form = EconomyForm(request.POST)
if form.is_valid():
subtype = form.cleaned_data['subtype']
region = form.cleaned_data['region']
#district = form.cleaned_data['district']
result = Economy.objects.filter(subtype=subtype)
return render_to_response('template.html', {'form': form,'page' : {'name':'Сельское хозяйство'},'result':result})
else :
form = EconomyForm()
return render_to_response('template.html', {'form': form,'page' : {'name':'Сельское хозяйство'},})