ordynacje/ordynacja/views.py~

22 lines
692 B
Python
Raw Permalink Normal View History

2018-06-16 11:22:13 +02:00
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from django.core import serializers
from .models import Glos,Komitet
def index(request):
return HttpResponse("This is main page. Here will be the map")
def okreg(request, okreg_id):
g = Glos.objects.filter(okreg__o_id=okreg_id)
template = loader.get_template('ordynacja/index.html')
context = {
'okreg_id': okreg_id,
'okreg_list': g,
'okreg_name': g[0].okreg.name,
'glosy_json': serializers.serialize('json', g),
'komitety': serializers.serialize('json', Komitet.objects.all())
}
return HttpResponse(template.render(context, request))