O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Example 28.35: Project Code

blog/sitemaps.py in 477533df0e

49   class PostArchiveSitemap(Sitemap): 50 51       def items(self): 52           year_dates ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required