Add posted entries to the sitemap

This commit is contained in:
Danielle McLean 2017-10-26 08:46:48 +11:00
parent 9d6cf902d1
commit dc99e7a39b
Signed by: 00dani
GPG Key ID: 5A5D2D1AFF12EEC5
2 changed files with 15 additions and 0 deletions

13
entries/sitemaps.py Normal file
View File

@ -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

View File

@ -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}