Reputation: 1829
hi I'm new in django I need to create a sitemap for my book modele but after doing this I can't find any xml file in my project directory .am i missed something? my sitemap.py is:
class BookSitemap(Sitemap):
changefreq = "weekly"
priority = 0.5
def items(self):
return Book.objects.all()
def lastmod(self, obj):
return obj.pub_date
url.py:
sitemaps = {
'book':BookSitemap,
}
url(r'^sitemap.xml$',
'django.contrib.sitemaps.views.index',
{'sitemaps': sitemaps}),
url(r'^sitemap-(?P<section>.+).xml$',
'django.contrib.sitemaps.views.sitemap',
{'sitemaps': sitemaps}),
setting.py
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
Upvotes: 4
Views: 2302
Reputation: 11048
from the docs:
This tells Django to build a sitemap when a client accesses /sitemap.xml.
the sitemap is not a static file, but it's an xml response each time somebody accesses your sitemap urls. the fastest way to test if it's working is fire up your django server and point your browser to one of your sitemaps (http://localhost:8000/sitemap-< your section identifier>.xml, in your case) and you should see it
Upvotes: 3