From dc99e7a39b66c1321c8a21e01348870510fca8d9 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Thu, 26 Oct 2017 08:46:48 +1100 Subject: [PATCH] Add posted entries to the sitemap --- entries/sitemaps.py | 13 +++++++++++++ lemoncurry/urls.py | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 entries/sitemaps.py 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}