我按照django站点上的sitemap激活步骤操作,但一直收到'TemplateDoesNotExist‘错误。也许我误解了,但是genericview不是应该生成页面吗?
########### url.py #############################3
.........
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
........
........
info_dict = {
'queryset': Bookmark.objects.all(),
'date_field': 'added'
}
sitemaps = {
'bookmarks': GenericSitemap(info_dict, changefreq = 'never', priority=0.6),
}
urlpatterns = patterns('',
.............
url(r'^$', 'microblogging.views.public', name="home"),
(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
.............
)
if settings.SERVE_MEDIA:
urlpatterns += patterns('',
(r'^site_media/(?P<path>.*)$', 'misc.views.serve')
)
############# error #############################
TemplateDoesNotExist at /sitemap.xml
sitemap.xml
Request Method: GET
Request URL: http://localhost:8000/sitemap.xml
Exception Type: TemplateDoesNotExist
Exception Value:
sitemap.xml
Exception Location: /usr/lib/python2.5/site-packages/django/template/loader.py in find_template_source, line 73
Python Executable: /usr/bin/python2.5
Python Version: 2.5.4发布于 2009-10-18 23:03:55
这是因为它没有找到默认的模板。
确保'django.template.loaders.app_directories.load_template_source'在您的TEMPLATE_LOADERS设置中,也确保'django.contrib.sitemaps'在您的INSTALLED_APPS中。
发布于 2013-03-13 03:34:47
已弃用,最新版本为:'django.template.loaders.app_directories.Loader',
发布于 2018-07-30 19:59:33
您可以尝试从INSTALLED_APPS中删除django.contrib.sites。
只需添加django.contrib.sitemaps即可。
https://stackoverflow.com/questions/1586273
复制相似问题