diff --git a/entries/sitemaps.py b/entries/sitemaps.py new file mode 100644 index 0000000..4a969c0 --- /dev/null +++ b/entries/sitemaps.py @@ -0,0 +1,13 @@ +from django.contrib import sitemaps +from .models import Entry + + +class EntriesSitemap(sitemaps.Sitemap): + def items(self): + return Entry.objects.all() + + def lastmod(self, entry): + return entry.updated + + def location(self, entry): + return entry.url diff --git a/lemoncurry/urls.py b/lemoncurry/urls.py index 41e07c8..ba8e45a 100644 --- a/lemoncurry/urls.py +++ b/lemoncurry/urls.py @@ -18,6 +18,7 @@ from django.contrib import admin from otp_agents.admin import TrustedAgentAdminSite import django.contrib.sitemaps.views as sitemap +from entries.sitemaps import EntriesSitemap from home.sitemaps import HomeSitemap otp_admin_site = TrustedAgentAdminSite() @@ -26,6 +27,7 @@ for model_cls, model_admin in admin.site._registry.items(): sections = { + 'entries': EntriesSitemap, 'home': HomeSitemap, } maps = {'sitemaps': sections}