Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'TemplateDoesNotExist' error with creating Sitemap for Django app

Tags:

django

sitemap

I followed the sitemap activation steps on the django site but i keep getting a 'TemplateDoesNotExist' error. Maybe i am misunderstanding, but isn't genericview supposed to generate the page?

########### 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
like image 685
ironic_username Avatar asked Oct 18 '09 22:10

ironic_username


2 Answers

This is because it's not finding the default templates.

Make sure 'django.template.loaders.app_directories.load_template_source' is in your TEMPLATE_LOADERS setting, and also make sure that 'django.contrib.sitemaps' is in your INSTALLED_APPS.

like image 110
Mez Avatar answered Sep 25 '22 04:09

Mez


deprecated, latest is: 'django.template.loaders.app_directories.Loader',

like image 20
Adam Spence Avatar answered Sep 22 '22 04:09

Adam Spence