add views

This commit is contained in:
Pratyush Desai 2022-09-09 08:28:57 +05:30
parent 2d050c10f4
commit 2b54e70f1b
Signed by: pratyush
GPG Key ID: DBA5BB7505946FAD
2 changed files with 19 additions and 1 deletions

View File

@ -4,4 +4,12 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='index'), path('', views.index, name='index'),
# ex: /polls/
path('', views.index, name='index'),
# ex: /polls/5/
path('<int:question_id>/', views.detail, name='detail'),
# ex: /polls/5/results/
path('<int:question_id>/results/', views.results, name='results'),
# ex: /polls/5/vote/
path('<int:question_id>/vote/', views.vote, name='vote'),
] ]

View File

@ -5,4 +5,14 @@ from django.http import HttpResponse
def index(request): def index(request):
return HttpResponse("Hello, world. You're at the polls index.") 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)