2012-11-12 48 views
2

當我嘗試訪問我的Django管理站點,我得到了以下錯誤:Django的導入錯誤在/管理/

ImportError at /admin/

No module named django.views

Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Django Version: 1.4.1 Exception Type: ImportError Exception Value:

No module named django.views

Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module, line 35 Python Executable: /usr/bin/python Python Version: 2.7.3

這裏是我的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('', 
    url(r'^$', include('home.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)), 
) 

當我發表評論行url(r'^$', include('home.urls')),管理網站工作againg。

我找不出我的問題是什麼。你可以幫我嗎?

回答

1

您在代碼中的其他位置有您自己的某個視圖中的錯誤,該錯誤正試圖導入django.views。管理網站需要導入所有視圖才能正確反向URL,即使它不在管理代碼本身中,也會觸發錯誤。

0

我不能肯定它是否熄滅雅渴望得到正確的答案。我試圖複製這個問題,並發現,而不是使用

include('home.urls') 

,如果你的東西取代它像

(admin.site.urls) 

,或者您也可以使用

url(r'^{{project_name}}', '{{project_name}}.{{app_name}}.views.{{some html template file}}'), 

然後它fine.Hope它至少可以幫助你縮小頁上影響的奧林匹克。