15

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
ironic_username
  • 205
  • 3
  • 9

4 Answers4

55

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.

Paolo Moretti
  • 54,162
  • 23
  • 101
  • 92
Mez
  • 24,430
  • 14
  • 71
  • 93
6

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

Adam Spence
  • 3,040
  • 1
  • 21
  • 17
3

You can try removing django.contrib.sites from the INSTALLED_APPS.

Just add the django.contrib.sitemaps.

cezar
  • 11,616
  • 6
  • 48
  • 84
0

There is no need to add django.template.loaders.app_directories.Loader any more.

jhd
  • 1,243
  • 9
  • 21