Django教程第1部分错误:URL与URL模式不匹配 [英] Django Tutorial Part 1 Error: URL does not match URL patterns
问题描述
我将在此处介绍Django教程:
I am going throught the Django tutorial here:
https://docs.djangoproject.com/en/1.10/intro/tutorial01/
我完全按照说明进行操作.但是,当我尝试转到 http://localhost:8000/polls/时,我看不到消息你好,世界.您在民意测验索引中."如预期的那样.相反,我收到以下错误:
I follow the instructions exactly. But when I try to go to http://localhost:8000/polls/, I don't see the message "Hello, world. You’re at the polls index." as expected. Instead, I get the following error:
Django使用mysite.urls中定义的URLconf,按以下顺序尝试了以下URL模式:^ admin/当前网址polls/与以上任何一个都不匹配.
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^admin/ The current URL, polls/, didn't match any of these.
这是我的mysite/urls.py文件.我不确定为什么无法识别urlpatterns中的第一个正则表达式模式.
Here is my mysite/urls.py file. I am not sure why the first regex pattern in urlpatterns is not recognized.
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^polls/', include('polls.urls')),
url(r'^admin/', admin.site.urls),
]
推荐答案
在请求页面时,您可能忘记了 views.py
中的 .html
扩展名.
You might have forgot .html
extension in views.py
while requesting the page.
这篇关于Django教程第1部分错误:URL与URL模式不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!