user_image
By  十一有一米八哟    On   2021年4月9日 17:08

老师,您好!按照您的教程,在 /polls/views.py/def detail 函数中捕获Http404异常 这一步骤。尝试访问不存在的question_id,但是网页返回以下错误(并未捕获到异常)(注意到并不是说didn't match any of these,而是匹配到了the last one,但仍跳404不返回“Question does not exist”。): Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/polls/5/ Raised by: polls.views.detail Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: polls/ [name='index'] polls/ <int:question_id>/ [name='detail'] The current path, polls/5/, matched the last one. You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.