Spaces:
Sleeping
Sleeping
Commit
·
bb001df
1
Parent(s):
98520ce
Prueba de detail
Browse files
app/polls/templates/polls/detail.html
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{{ question }}
|
app/polls/views.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from django.http import HttpResponse
|
2 |
from django.template import loader
|
3 |
-
|
|
|
4 |
|
5 |
from .models import Question
|
6 |
|
@@ -14,7 +15,12 @@ def index(request):
|
|
14 |
|
15 |
# Leave the rest of the views (detail, results, vote) unchanged
|
16 |
def detail(request, question_id):
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
def results(request, question_id):
|
20 |
response = "You're looking at the results of question %s."
|
|
|
1 |
from django.http import HttpResponse
|
2 |
from django.template import loader
|
3 |
+
from django.http import Http404
|
4 |
+
from django.shortcuts import render
|
5 |
|
6 |
from .models import Question
|
7 |
|
|
|
15 |
|
16 |
# Leave the rest of the views (detail, results, vote) unchanged
|
17 |
def detail(request, question_id):
|
18 |
+
try:
|
19 |
+
question = Question.objects.get(pk=question_id)
|
20 |
+
except Question.DoesNotExist:
|
21 |
+
raise Http404("Question does not exist")
|
22 |
+
return render(request, 'polls/detail.html', {'question': question})
|
23 |
+
|
24 |
|
25 |
def results(request, question_id):
|
26 |
response = "You're looking at the results of question %s."
|