28.3.4 Blog Post Archive Sitemap
For the webpages that list Post
objects according to date, I want to do something a little different. I want to list pages for both the year and the month archives, and I want these pages to be sorted according to date, so that the month archives appear before the year archives (for the same year). These requirements seem a little silly, but they force us to customize the Sitemap
a little more than before.
To start, we can get all of the dates for the Post
objects, first according to year, and then according to month, as shown in Example 28.35.
blog/sitemaps.py
in 477533df0e
49 class PostArchiveSitemap(Sitemap): 50 51 def items(self): 52 year_dates ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.