diff --git a/LCAdmin/db.sqlite3 b/LCAdmin/db.sqlite3 index 19e8834..b72e62f 100644 Binary files a/LCAdmin/db.sqlite3 and b/LCAdmin/db.sqlite3 differ diff --git a/LCAdmin/polls/templates/polls/details.html b/LCAdmin/polls/templates/polls/details.html new file mode 100644 index 0000000..4e1bd67 --- /dev/null +++ b/LCAdmin/polls/templates/polls/details.html @@ -0,0 +1,6 @@ +

{{ question.question_text }}

+ \ No newline at end of file diff --git a/LCAdmin/polls/templates/polls/index.html b/LCAdmin/polls/templates/polls/index.html new file mode 100644 index 0000000..9e8a98a --- /dev/null +++ b/LCAdmin/polls/templates/polls/index.html @@ -0,0 +1,9 @@ +{% if latest_question_list %} + +{% else %} +

No polls are available.

+{% endif %} \ No newline at end of file diff --git a/LCAdmin/polls/urls.py b/LCAdmin/polls/urls.py index 94083df..b124599 100644 --- a/LCAdmin/polls/urls.py +++ b/LCAdmin/polls/urls.py @@ -1,15 +1,10 @@ from django.urls import path from . import views - +app_name = 'polls' urlpatterns = [ path('', views.index, name='index'), - # ex: /polls/ - path('', views.index, name='index'), - # ex: /polls/5/ path('/', views.detail, name='detail'), - # ex: /polls/5/results/ path('/results/', views.results, name='results'), - # ex: /polls/5/vote/ path('/vote/', views.vote, name='vote'), ] \ No newline at end of file diff --git a/LCAdmin/polls/views.py b/LCAdmin/polls/views.py index d5f37f2..ca0fea2 100644 --- a/LCAdmin/polls/views.py +++ b/LCAdmin/polls/views.py @@ -1,14 +1,18 @@ from django.shortcuts import render - -# Create your views here. from django.http import HttpResponse +from django.shortcuts import get_object_or_404, render + +from .models import Question 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): - return HttpResponse("You're looking at question %s." % question_id) + question = get_object_or_404(Question, pk=question_id) + return render(request, 'polls/detail.html', {'question': question}) def results(request, question_id): response = "You're looking at the results of question %s."