views.py 683 Bytes
from django.shortcuts import render
from django.db.models import Count
from .models import RT_edu, Maps, RT_agri_policy

# Create your views here.           

def dbselect(dbnameis):
    if dbnameis=='agri':
        policys = RT_agri_policy.objects.values('cntr').annotate(count=Count('cntr'))
        return policys
    elif dbnameis=='normal':
        educations = RT_edu.objects.values(city='city').annotate(count=Count('city'))
        return educations


def maplist(request):
    mapp = Maps.objects.get(id=10)
    mapp = mapp.mapdata
    exportdatas = dbselect('agri')
    context = {'exportdata': exportdatas, 'maps':mapp}
    return render(request, 'maplist.html', context)