Python 在django tututorial中找不到页面(404)

Python 在django tututorial中找不到页面(404),python,django,Python,Django,我正在努力 将url.py更改为 from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'mysite.views

我正在努力

将url.py更改为

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

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'mysite.views.home', name='home'),
    # url(r'^mysite/', include('mysite.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
      url(r'^admin/', include(admin.site.urls)),
)
启动runserver时,我会得到以下信息:

404 error

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^admin/
The current URL, , didn't match any of these.
有没有什么明显的迹象表明我做错了

提前感谢,


Bill

您没有定义基本url。你需要像这样的东西-

urlpatterns = patterns('',

    # ...
    url(r'^$', HomeView.as_view())

)
您应该能够在-localhost:8000/admin/(假设您正在使用
python manage.py runserver
运行开发服务器)上看到您的站点

Django检查您在URL conf文件中定义的所有URL,并查找与您在浏览器中输入的URL匹配的URL。如果它找到一个匹配的URL,那么它将提供由URL的相应视图返回的http响应(
HomeView
,在上面的代码中)。url.py文件将url与视图相匹配。视图返回http响应

查看您收到的错误消息(以及从
url.py
文件中包含的代码),您可以看到应用程序中只定义了一个url-
admin/
。尝试在任何其他url获取页面将失败


有关更多信息,请查看。

好吧,看起来您试图点击一个空url,但尚未定义空url的位置。我猜您的意思不是“启动runserver”,而是运行
manage.py runserver
,然后在浏览器中点击localhost:8000,出现此错误?感谢提供详细信息