Created
December 18, 2017 12:00
-
-
Save solidpple/9b6c9bcbd165596ef713ade155f8f66c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import get_object_or_404, render | |
from django.http import HttpResponseRedirect | |
from django.urls import reverse | |
from django.views import generic | |
from .models import Choice, Question | |
class IndexView(generic.ListView): | |
template_name = 'polls/index.html' | |
context_object_name = 'latest_question_list' | |
def get_queryset(self): | |
"""Return the last five published questions.""" | |
return Question.objects.order_by('-pub_date')[:5] | |
class DetailView(generic.DetailView): | |
model = Question | |
template_name = 'polls/detail.html' | |
class ResultsView(generic.DetailView): | |
model = Question | |
template_name = 'polls/results.html' | |
def vote(request, question_id): | |
... # same as above, no changes needed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment