在這個網站上有許多類似這個問題,但我找不到能解釋這種特殊行爲的問題。Django 1.3.7 TemplateDoesNotExist錯誤admin/index.html
我對django和ubuntu比較新,所以也許解釋很簡單。這是我嘗試遷移到新服務器的舊版(v1.3.7)django項目。
以下是完整的錯誤,我在我的Apache日誌越來越:
TemplateDoesNotExist at /admin/
admin/login.html
Request Method: GET
Request URL: http://131.212.123.7:26080/glrimon/admin/
Django Version: 1.3.7
Exception Type: TemplateDoesNotExist
Exception Value:
admin/login.html
Exception Location: /.../leave_beave/lib/python2.7/site-packages/django/template/loader.py in find_template, line 138
Python Executable: /.../leave_beave/bin/python
leave_beave
是我的virtualenv的名稱。
這裏是沿回溯傳遞的信息:
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/glri_mon/siteweb/templates/admin/login.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/glri_mon/siteweb/gps_upload/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/siteapp/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/glrimon_models/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/sdde/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/dv/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/contains/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/sqlwrite/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/tinymce/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/mptt/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/menus/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/text/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/picture/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/link/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/file/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/snippet/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/cmsplugin_rst/templates/admin/login.html (File does not exist)
glri_mon
是Django項目目錄。 下面是相關模板的路徑:/.../leave_beave/django/contrib/admin/templates/admin/index.html
。有關django爲什麼沒有在搜索中包含該路徑的想法?
這裏是我的模板加載從settings.py:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
我收到同樣的錯誤了較早的問題,我通過創建從問題(.../python2.7/site-packages/lib.../package/templates
)模板目錄符號鏈接解決它我/project_dir/templates
目錄,這是一個設置爲我的模板目錄settings.py:
TEMPLATE_DIRS = (
os.path.join(PATH, 'templates'),
)
我這樣做的時候,因爲我認爲這是一個一次性的解決方案黑客之類的事情,但我現在米得到相同的錯誤嘗試訪問我的網站的管理頁面(http://.../admin/)。這告訴我我正在討論這個錯誤。
我想我可以爲每個模板目錄添加一個符號鏈接來產生這個錯誤,但這似乎不是一個生產站點的好主意。
我在這裏錯過了什麼?
你在'INSTALLED_APPS'設置中有'django.contrib.admin'嗎? – Alasdair
我的確如此。感謝您的檢查。 – rumski20
由於您在Apache中運行,您將需要設置靜態文件。你有沒有這樣做? – Dashdrum