Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #21112 -- Make sure sitemaps with no lastmod date work correctly.

Thanks to Matthias Kestenholz for the report and patch.
  • Loading branch information...
commit f5f662fa5f4efd1f0fdd7901ed58c34f384af532 1 parent 9400142
@charettes charettes authored
View
1  AUTHORS
@@ -338,6 +338,7 @@ answer newbie questions, and generally made Django that much better:
Niall Kelly <duke.sam.vimes@gmail.com>
Ryan Kelly <ryan@rfk.id.au>
Thomas Kerpe <thomas@kerpe.net>
+ Matthias Kestenholz <mk@406.ch>
Wiley Kestner <wiley.kestner@gmail.com>
Ossama M. Khayat <okhayat@yahoo.com>
Ben Khoo <khoobks@westnet.com.au>
View
2  django/contrib/sitemaps/__init__.py
@@ -102,7 +102,7 @@ def get_urls(self, page=1, site=None, protocol=None):
'priority': str(priority if priority is not None else ''),
}
urls.append(url_info)
- if all_items_lastmod:
+ if all_items_lastmod and latest_lastmod:
self.latest_lastmod = latest_lastmod
return urls
View
4 django/contrib/sitemaps/tests/test_http.py
@@ -166,3 +166,7 @@ def test_x_robots_sitemap(self):
response = self.client.get('/simple/sitemap.xml')
self.assertEqual(response['X-Robots-Tag'], 'noindex, noodp, noarchive')
+
+ def test_empty_sitemap(self):
+ response = self.client.get('/empty/sitemap.xml')
+ self.assertEqual(response.status_code, 200)
View
14 django/contrib/sitemaps/tests/urls/http.py
@@ -16,6 +16,15 @@ def items(self):
return [object()]
+class EmptySitemap(Sitemap):
+ changefreq = "never"
+ priority = 0.5
+ location = '/location/'
+
+ def items(self):
+ return []
+
+
class FixedLastmodSitemap(SimpleSitemap):
lastmod = datetime(2013, 3, 13, 10, 0, 0)
@@ -37,6 +46,10 @@ def items(self):
'simple': SimpleSitemap,
}
+empty_sitemaps = {
+ 'empty': EmptySitemap,
+}
+
fixed_lastmod_sitemaps = {
'fixed-lastmod': FixedLastmodSitemap,
}
@@ -62,6 +75,7 @@ def items(self):
(r'^simple/sitemap\.xml$', 'sitemap', {'sitemaps': simple_sitemaps}),
(r'^simple/custom-sitemap\.xml$', 'sitemap',
{'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap.xml'}),
+ (r'^empty/sitemap\.xml$', 'sitemap', {'sitemaps': empty_sitemaps}),
(r'^lastmod/sitemap\.xml$', 'sitemap', {'sitemaps': fixed_lastmod_sitemaps}),
(r'^lastmod-mixed/sitemap\.xml$', 'sitemap', {'sitemaps': fixed_lastmod__mixed_sitemaps}),
(r'^generic/sitemap\.xml$', 'sitemap', {'sitemaps': generic_sitemaps}),
Please sign in to comment.
Something went wrong with that request. Please try again.