【发布时间】:2013-10-13 10:40:26
【问题描述】:
我是 Django 和 Python 的新手。我只做过php。
我尝试了 3 次,但我几乎已经正确安装了 Django。我按照教程安装它,它工作。所以我启用了管理员、面板并设置了 mysql。
管理面板正常工作,我有我的静态文件夹,所以它也有所有的 css。但是当我进入主页时,我得到了这个 404。(我的项目名为 firstweb)所以当我进入 firstweb 时,有一个 404,但 firstweb/admin 工作。
Using the URLconf defined in firstweb.urls, Django tried these URL patterns, in this order:
1. ^admin/
The current URL, firstweb/, didn't match any of these.
我对整个 runserver 的事情感到困惑。那是不是我的 Apache 以外的其他小服务器?为什么每次都需要启动?
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'^$', 'firstweb.views.home', name='home'),
# url(r'^firstweb/', include('firstweb.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)),
)
【问题讨论】:
-
默认情况下,django pre 1.5 未启用管理员,请按照此处的步骤操作:docs.djangoproject.com/en/1.5/ref/contrib/admin/#overview
-
runserver仅用于本地开发,不适用于在生产中运行您的站点。 -
Karth,管理面板已启用并且可以正常工作。我提到过。主页有404。管理员零问题。
-
@gregor - 根据您的 urls.py 文件的顺序,它可能会拾取各个管理页面,但不会拾取主页。你能显示你的 urls 文件吗?顺序可能很重要。
-
@Joseph,将其添加到上面的 OP 中。
标签: django debian django-urls django-settings