ordynacje/ordynacja/views.py

22 lines
692 B
Python
Raw Normal View History

2018-06-06 17:52:09 +02:00
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
2018-06-16 11:22:13 +02:00
from django.core import serializers
from .models import Glos,Komitet
2018-06-06 17:52:09 +02:00
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 = {
2018-06-16 11:22:13 +02:00
'okreg_id': okreg_id,
2018-06-06 17:52:09 +02:00
'okreg_list': g,
2018-06-16 11:22:13 +02:00
'okreg_name': g[0].okreg.name,
'glosy_json': serializers.serialize('json', g),
'komitety': serializers.serialize('json', Komitet.objects.all())
2018-06-06 17:52:09 +02:00
}
return HttpResponse(template.render(context, request))