We therefore need a
Sitemap subclass. We can start with our blog app, creating a
sitemaps.py file where we import our tools, as shown in Example 28.22.
1 from datetime import date 2 3 from django.contrib.sitemaps import Sitemap 4 5 from .models import Post
We then declare our subclass in Example 28.23. The goal is to provide a list of all of the pages in our blog app. Because we’ve implemented
Post, this turns out to be surprisingly easy: we just need to return a list of
Post objects in the
items() method. We can also tell the search engine when the
Post instance was modified thanks to the
lastmod() method. ...