404在Django 1.11应用程序中设置视图时出错

2024-09-27 00:18:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是MacOS HighSierra、django 1.11和Python2.7.14。每当我设置视图并运行服务器时,polls/1都会返回404错误。我正在学习官方的django课程。页面上写着-

Page not found (404)
Request Method: GET
Request URL:    http://localhost:8000/polls/1
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:

^polls/ ^$ [name='index']
^polls/ ^(?P<question_id>[0-9]+)/$, [name='detail']
^polls/ ^(?P<question_id>[0-9]+)/results/$, [name='results']
^polls/ ^(?P<question_id>[0-9]+)/vote/$, [name='vote']
^admin/
The current path, polls/1, didn't match any of these.

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.

Tags: djangonameinidurlrequestmacosthis

热门问题