我遵循Django教程第1部分,現在在第2部分,我應該讓管理界面啓動並運行。在教程中的URL匹配失敗(管理員)
我非常認真地跟着一步,但是當我嘗試加載網站,我收到以下錯誤:
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
1. ^admin/
The current URL, , didn't match any of these.
我settings.py第一註釋掉「django.contrib.admin」:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'polls',
)
... ...之後,我跑蟒蛇manage.py執行syncdb,其輸出:
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
...然後我未註釋的是我應該根據教程,在urls.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)),
)
如上所述,這如果運行產生錯誤消息。
什麼可能是錯的?我的意思是我完全按照假設跟着教程。
你有沒有嘗試添加admin.py投票? https://docs.djangoproject.com/zh/dev/intro/tutorial02/#make-the-poll-app-modifiable-in-the-admin – Pramod 2013-02-24 16:19:11
現在嘗試了。一樣。 – holyredbeard 2013-02-24 16:24:08