I'm trying to add sitemaps on a per object base to my project.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b74b4fe0-3479-4363-8169-0d5fe2ac122a%40googlegroups.com.
urlpatterns = (
path('<path:path>/', views.page_detail, name="page"),
path('<path:path>/sitemap.xml', cache_page(60*60)(views.sitemap_view),
name="sitemap-index"),
)
def sitemap_view(request, path='/'):
sitemaps = {}
top_page = get_object_or_404(
Page.objects.active(),
path=f"/{path}/" if path else '/',
)
sitemaps['pages'] = PageSitemap(top_page)
for blog_page in top_page.descendants(include_self=True).filter(application='blog'):
sitemaps[blog_page.slug] = ArticleSitemap(blog_page)
for event_page in top_page.descendants(include_self=True).filter(application='events'):
sitemaps[event_page.slug] = EventSitemap(event_page)
for category_page in top_page.descendants(include_self=True).filter(application='categories'):
sitemaps[category_page.slug] = CategorySitemap(category_page)
return sitemap_view(
request, sitemaps,
)
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/7791e496-e225-4dca-a57b-fca9851c34db%40googlegroups.com.