我目前陷入了django教程的第3部分。 民意调查views.py是......
from django.http import HttpResponse
def index(request):
return HttpResponse("<strong>Welcome to the poll index page!</strong>")
民意调查网址是......
from django.conf.urls import patterns, url
from polls import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index')
)
mysite网址是......
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)),
)
我每次跑步都得到......
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^polls/
^admin/
The current URL, , didn't match any of these.
似乎无法弄清楚这里有什么问题,有什么提示吗?
答案 0 :(得分:0)
这里的问题是您指向尚未定义的 localhost:8000 ,您定义的路由是 localhost:8000 / admin 和本地主机:8000 /轮询即可。访问那些以使您的网址正常工作或尝试更改以下网址,以便在 localhost:8000 本身进行民意调查
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^/$', include('polls.urls')),
url(r'^admin/$', include(admin.site.urls)),
)
希望它有所帮助。