Fixed #25916 -- Added lastmod support to sitemap index view.

Co-authored-by: Matthew Downey <matthew.downey@webit.com.au>
This commit is contained in:
David Smith 2020-12-30 16:44:53 +00:00 committed by Carlton Gibson
parent 2ce03a2bac
commit 480191244d
11 changed files with 295 additions and 45 deletions

View file

@ -85,3 +85,12 @@ class GenericViewsSitemapTests(SitemapTestsBase):
)
with self.assertWarnsMessage(RemovedInDjango50Warning, msg):
sitemap.get_protocol()
def test_generic_sitemap_index(self):
TestModel.objects.update(lastmod=datetime(2013, 3, 13, 10, 0, 0))
response = self.client.get('/generic-lastmod/index.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>http://example.com/simple/sitemap-generic.xml</loc><lastmod>2013-03-13T10:00:00</lastmod></sitemap>
</sitemapindex>"""
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)