django 1.6 tutorial3“当前网址与任何模式都不匹配”

时间:2014-01-06 23:49:57

标签: django-views django-urls django-1.6

Python 2.7.3

我是django的新手,我正在关注教程: https://docs.djangoproject.com/en/1.6/intro/tutorial03/

我完全遵循了描述的步骤:

以下是项目中文件的复制/粘贴:

cat polls / views.py

from django.http import HttpResponse

def index(request):
        return HttpResponse("Hello, world. You're at the poll index.")
来自/ mysite的

cat urls.py

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^polls/', include('polls.urls')'),
    url(r'^admin/', include(admin.site.urls)'),
)

cat polls / urls.py

from django.conf.urls import patterns, url

from polls import views

urlpatterns = patterns('',
    url(r'^$', views.index, name='index')
)

页面调试显示以下错误: enter image description here

看起来,它无法识别/mysite/urls.py中的“民意调查”模式。

我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

我认为问题出在

url(r'^polls/', include('polls.urls')'),

将其更改为:(来自https://docs.djangoproject.com/en/1.6/intro/tutorial03/处的文档)

url(r'^polls/', include('polls.urls')),