Я установил карту сайта django, используя встроенную в django структуру карты сайта.
Однако, несмотря на то, что содержимое карты сайта выглядит нормально, оно не генерирует типичную информацию о стиле / формате для карты сайта.И при просмотре в браузере я вижу ошибку:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
Помимо этой ошибки, карта сайта отображается правильно:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.myexample.com/</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://www.myexample.com/about/</loc>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
<url>
....
файл моей карты сайта sitemaps.pyэто:
from django.contrib.sitemaps import Sitemap
from django.urls import reverse
class HomeSitemap(Sitemap):
"""Reverse static views for XML sitemap"""
changefreq = "daily"
priority = 1.0
def items(self):
return ['home', ]
def location(self, item):
return reverse(item)
class StaticSitemap(Sitemap):
"""Reverse static views for XML sitemap"""
changefreq = "daily"
priority = 0.9
def items(self):
return ['about', 'faq', 'contact', 'terms', 'privacy', 'signup']
def location(self, item):
return reverse(item)
urls.py соответствующий раздел
...
sitemaps = {'home': HomeSitemap, 'static': StaticSitemap}
...
url(r'^sitemap\.xml/$', sitemap, {'sitemaps': sitemaps}, name='signup'),