You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
660 B
41 lines
660 B
from django.shortcuts import render, get_object_or_404
|
|
|
|
from polls.models import Poll, Option
|
|
|
|
|
|
def polls(
|
|
request,
|
|
):
|
|
context = {}
|
|
|
|
context["polls"] = Poll.objects.all()
|
|
|
|
return render(
|
|
request,
|
|
template_name="polls/polls.html",
|
|
context=context,
|
|
)
|
|
|
|
|
|
def poll_details(
|
|
request,
|
|
poll_id,
|
|
):
|
|
poll = get_object_or_404(
|
|
Poll,
|
|
pk=poll_id,
|
|
)
|
|
|
|
context = {}
|
|
|
|
context["poll"] = poll
|
|
context["options"] = Option.objects.filter(
|
|
poll=poll,
|
|
)
|
|
|
|
return render(
|
|
request,
|
|
template_name="polls/poll_details.html",
|
|
context=context,
|
|
)
|