我跟着this教程,在我添加模板并将模式放入urls.py后,我去了网站,我得到一个模板未加载页面。Django模板问题
这是我的模板迪尔斯从settings.py部分:
TEMPLATE_DIRS = (
"/home/django-projects/base/templates/",
)
基础文件夹层次结构是这样的:
blog
dbs
__init__.py
manage.py
settings.py
templates
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:
2010-11-02
Kevin
+0
我们可以有更多关于失败的信息吗?我想你有Debug = True,所以你可以给我们一些关于错误的更多细节。 –
2010-11-02 15:49:19
+0
跟踪结束:异常类型:TemplateBitleNotExist at /bbase.html 异常值:list.html –
2010-11-02 16:22:32