'TemplateDoesNotExist' error with creating Sitemap for Django app
Asked Answered
M

4

17

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
Meandrous answered 18/10, 2009 at 22:59 Comment(0)
N
57

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.

Notus answered 18/10, 2009 at 23:3 Comment(2)
Yes, they are both in my settings file.Meandrous
Ahh! because i had setup settings.py/local_settings.py for dev/production , i forgot to add it to local_settings.pyMeandrous
S
6

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

Sulamith answered 12/3, 2013 at 19:34 Comment(0)
O
6

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

Just add the django.contrib.sitemaps.

Oregon answered 30/7, 2018 at 11:59 Comment(0)
L
0

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

Laminar answered 5/6, 2018 at 6:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.