28.3.3 Startup Sitemap

Most of the values in a sitemap are actually optional (Django will fill them in for you). In our StartupSitemap, we can simply implement items(). The lastmod() implementation is not necessary, but it is a nice way to associate our startups with a date, as shown in Example 28.33.

Example 28.33: Project Code

organizer/sitemaps.py in aabf064551

14   class StartupSitemap(Sitemap): 15 16       def items(self): 17           return Startup.objects.all() 18 19       def lastmod(self, startup): 20           if startup.newslink_set.exists(): 21               return ( 22                   startup.newslink_set.latest() 23                   .pub_date) 24           else: 25               return startup.founded_date ...

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.