Compare commits
2 Commits
3da064e3af
...
dfcf39539b
| Author | SHA1 | Date | |
|---|---|---|---|
| dfcf39539b | |||
| f850f1f3e4 |
9
polls/templates/polls/index.html
Normal file
9
polls/templates/polls/index.html
Normal 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 %}
|
||||
@ -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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user