From 2b54e70f1b3fc2bdcdda43ed1d7b9be57e0b2c4e Mon Sep 17 00:00:00 2001 From: Pratyush Desai Date: Fri, 9 Sep 2022 08:28:57 +0530 Subject: [PATCH] add views --- LCAdmin/polls/urls.py | 8 ++++++++ LCAdmin/polls/views.py | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/LCAdmin/polls/urls.py b/LCAdmin/polls/urls.py index 3ef24d9..94083df 100644 --- a/LCAdmin/polls/urls.py +++ b/LCAdmin/polls/urls.py @@ -4,4 +4,12 @@ from . import views 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 363c279..d5f37f2 100644 --- a/LCAdmin/polls/views.py +++ b/LCAdmin/polls/views.py @@ -5,4 +5,14 @@ from django.http import HttpResponse def index(request): - return HttpResponse("Hello, world. You're at the polls index.") \ No newline at end of file + return HttpResponse("Hello, world. You're at the polls index.") + +def detail(request, question_id): + return HttpResponse("You're looking at question %s." % question_id) + +def results(request, question_id): + response = "You're looking at the results of question %s." + return HttpResponse(response % question_id) + +def vote(request, question_id): + return HttpResponse("You're voting on question %s." % question_id) \ No newline at end of file