Add posted entries to the sitemap
This commit is contained in:
parent
9d6cf902d1
commit
dc99e7a39b
2 changed files with 15 additions and 0 deletions
13
entries/sitemaps.py
Normal file
13
entries/sitemaps.py
Normal 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
|
|
@ -18,6 +18,7 @@ from django.contrib import admin
|
||||||
from otp_agents.admin import TrustedAgentAdminSite
|
from otp_agents.admin import TrustedAgentAdminSite
|
||||||
|
|
||||||
import django.contrib.sitemaps.views as sitemap
|
import django.contrib.sitemaps.views as sitemap
|
||||||
|
from entries.sitemaps import EntriesSitemap
|
||||||
from home.sitemaps import HomeSitemap
|
from home.sitemaps import HomeSitemap
|
||||||
|
|
||||||
otp_admin_site = TrustedAgentAdminSite()
|
otp_admin_site = TrustedAgentAdminSite()
|
||||||
|
@ -26,6 +27,7 @@ for model_cls, model_admin in admin.site._registry.items():
|
||||||
|
|
||||||
|
|
||||||
sections = {
|
sections = {
|
||||||
|
'entries': EntriesSitemap,
|
||||||
'home': HomeSitemap,
|
'home': HomeSitemap,
|
||||||
}
|
}
|
||||||
maps = {'sitemaps': sections}
|
maps = {'sitemaps': sections}
|
||||||
|
|
Loading…
Reference in a new issue