We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cf8350e commit 0cde884Copy full SHA for 0cde884
polls/templates/polls/index.html
@@ -0,0 +1,9 @@
1
+{% if latest_question_list %}
2
+ <ul>
3
+ {% for question in latest_question_list %}
4
+ <li><a href="/polls/{{ question.id }}/">{{ question.question_text }}</a></li>
5
+ {% endfor %}
6
+ </ul>
7
+{% else %}
8
+ <p>No polls are available.</p>
9
+{% endif %}
polls/views.py
@@ -1,3 +1,8 @@
from django.shortcuts import render
+from polls.models import Question
-# Create your views here.
+
+def index(request):
+ latest_question_list = Question.objects.all().order_by('-pub_date')[:5]
+ context = {'latest_question_list': latest_question_list}
+ return render(request, 'polls/index.html', context)
0 commit comments