add polls url and view

main
roger 2 years ago
parent ee7191cbd6
commit a8ab36ffd6
  1. 3
      polls/urls.py
  2. 12
      polls/views.py

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

@ -6,3 +6,15 @@ from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, Django. U are at the polls index")
def detail(request, question_id):
return HttpResponse(f"You're looking at question {question_id}.")
def result(request, question_id):
return HttpResponse(f"You're looking at the result of question {question_id}.")
def vote(request, question_id):
return HttpResponse(f"You're voting on question {question_id}")

Loading…
Cancel
Save