From f65d961ae0e874854ca1cf6a0bacfdd6b7b1466b Mon Sep 17 00:00:00 2001 From: Stein Strindhaug Date: Thu, 26 Oct 2017 12:53:05 +0200 Subject: [PATCH] Tolerate sites where all pages are private (#3974) When all pages on a site is private, the last_mods set will be empty causing a crash when trying to get the max value from it. This fix adds a test that the set is truthy (not empty) before calling max. --- wagtail/contrib/wagtailsitemaps/sitemap_generator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wagtail/contrib/wagtailsitemaps/sitemap_generator.py b/wagtail/contrib/wagtailsitemaps/sitemap_generator.py index c2cde386f..f6651becf 100644 --- a/wagtail/contrib/wagtailsitemaps/sitemap_generator.py +++ b/wagtail/contrib/wagtailsitemaps/sitemap_generator.py @@ -35,6 +35,7 @@ class Sitemap(DjangoSitemap): urls.append(url_info) last_mods.add(url_info.get('lastmod')) - if None not in last_mods: + # last_mods might be empty if the whole site is private + if last_mods and None not in last_mods: self.latest_lastmod = max(last_mods) return urls