Python Django 4.2.5 Tutorial: Throwing 404 Error (Using Http404)

Insert image description here

from django.http import Http404
from django.shortcuts import render

from .models import Question
# ...
def detail(request, question_id):
    try:
        question = Question.objects.get(pk=question_id)
    except Question.DoesNotExist:
        raise Http404("Question does not exist")
    return render(request, 'polls/detail.html', {
    
    'question': question})

links:
throws 404 error

Guess you like

Origin blog.csdn.net/a772304419/article/details/133531553