10.返回404错误
1、修改detail视图函数
# polls/views.py
from django.shortcuts import render, get_object_or_404
def detail(request, question_id):
question = get_object_or_404(Question, pk=question_id)
return render(request, "polls/detail.html", {"question": question})
2、添加detail页面
# polls/templates/polls/detail.html
<h1>{{ question.question_text }}</h1>
<ul>
{% for choice in question.choice_set.all %}
<li>{{ choice.choice_text }}</li>
{% endfor %}
</ul>
4、访问存在的问题测试

3、访问不存在的问题测试

浙公网安备 33010602011771号