我跟着this教程,在我添加模板並將模式放入urls.py後,我去了網站,我得到一個模板未加載頁面。Django模板問題
這是我的模板迪爾斯從settings.py部分:
TEMPLATE_DIRS = (
"/home/django-projects/base/templates/",
)
基礎文件夾層次結構是這樣的:
blog<dir>
dbs<dir>
__init__.py
manage.py
settings.py
templates<dir>
urls.py
urls.py看起來是這樣的:
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('base.blog.views',
(r"", "main"),
# Example:
# (r'^base/', include('base.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
在模板中,我有一個名爲blog的文件夾,它包含教程中的兩個html文件。我只是不確定我缺少什麼設置來顯示正確的模板。我會很高興發佈任何你需要看到的東西。我相信這是微不足道的,我似乎無法弄清楚它是什麼。謝謝你的幫助。
編輯 所以我正在玩它,我意識到我無法去管理員。因此,我將博客部分的主要鏈接從網址脫離。在頂層的urls.py看起來是這樣的:
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'blog/', include('blog.urls')),
# Example:
# (r'^base/', include('base.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
在博客文件夾urls.py看起來是這樣的:從 進口django.conf.urls.defaults *
urlpatterns = patterns('base.blog.views',
(r'^$', 'main'),
)
現在我可以訪問管理員,但是當我嘗試訪問博客時仍然出現模板加載錯誤。
TemplateDoesNotExist at /blog/
blog/list.html
Request Method: GET
Request URL: http://192.168.1.124:9999/blog/
Django Version: 1.2.3
Exception Type: TemplateDoesNotExist
Exception Value:
blog/list.html
Exception Location: /usr/local/lib/python2.6/dist-packages/Django-1.2.3-py2.6.egg/django/template/loader.py in find_template, line 138
Python Executable: /usr/bin/python
Python Version: 2.6.6
Python Path: ['/home/kevin/django-projects/base', '/usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/BeautifulSoup-3.1.0.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Django-1.2.3-py2.6.egg', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0']
Server time: Tue, 2 Nov 2010 11:59:13 -0500
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
我們可以有更多關於失敗的信息嗎?我想你有Debug = True,所以你可以給我們一些關於錯誤的更多細節。 – 2010-11-02 15:49:19
跟蹤結束:異常類型:TemplateBitleNotExist at /bbase.html 異常值:list.html – Kevin 2010-11-02 16:22:32