Compare commits

...

2 Commits

Author SHA1 Message Date
dfcf39539b created shortcut 2025-11-22 20:40:59 -06:00
f850f1f3e4 added template 2025-11-22 20:35:45 -06:00
2 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,9 @@
{% if latest_question_list %}
<ul>
{% for question in latest_question_list %}
<li><a href="/polls/{{ question.id }}/">{{ question.question_text }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}

View File

@ -1,11 +1,16 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from .models import Question
# Create your views here.
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
latest_question_list = Question.objects.order_by("-pub_date")[:5]
context = {"latest_question_list": latest_question_list}
return render(request, "polls/index.html", context)
def detail(request, question_id):