mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Refs #27395 -- Added XML namespace declaration to sitemap template.
As per Google recommendations: https://support.google.com/webmasters/answer/189077?hl=en
This commit is contained in:
		
				
					committed by
					
						 Carlton Gibson
						Carlton Gibson
					
				
			
			
				
	
			
			
			
						parent
						
							948a874425
						
					
				
				
					commit
					50e1ccbbea
				
			| @@ -1,5 +1,5 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
| {% spaceless %} | {% spaceless %} | ||||||
| {% for url in urlset %} | {% for url in urlset %} | ||||||
|   <url> |   <url> | ||||||
|   | |||||||
| @@ -40,7 +40,7 @@ class GenericViewsSitemapTests(SitemapTestsBase): | |||||||
|         for pk in TestModel.objects.values_list("id", flat=True): |         for pk in TestModel.objects.values_list("id", flat=True): | ||||||
|             expected += "<url><loc>%s/testmodel/%s/</loc></url>" % (self.base_url, pk) |             expected += "<url><loc>%s/testmodel/%s/</loc></url>" % (self.base_url, pk) | ||||||
|         expected_content = """<?xml version="1.0" encoding="UTF-8"?> |         expected_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
| %s | %s | ||||||
| </urlset> | </urlset> | ||||||
| """ % expected | """ % expected | ||||||
| @@ -51,7 +51,7 @@ class GenericViewsSitemapTests(SitemapTestsBase): | |||||||
|         TestModel.objects.update(lastmod=datetime(2013, 3, 13, 10, 0, 0)) |         TestModel.objects.update(lastmod=datetime(2013, 3, 13, 10, 0, 0)) | ||||||
|         response = self.client.get('/generic-lastmod/sitemap.xml') |         response = self.client.get('/generic-lastmod/sitemap.xml') | ||||||
|         expected_content = """<?xml version="1.0" encoding="UTF-8"?> |         expected_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
| <url><loc>%s/testmodel/%s/</loc><lastmod>2013-03-13</lastmod></url> | <url><loc>%s/testmodel/%s/</loc><lastmod>2013-03-13</lastmod></url> | ||||||
| </urlset> | </urlset> | ||||||
| """ % (self.base_url, test_model.pk) | """ % (self.base_url, test_model.pk) | ||||||
|   | |||||||
| @@ -67,7 +67,7 @@ class HTTPSitemapTests(SitemapTestsBase): | |||||||
|         "A simple sitemap section can be rendered" |         "A simple sitemap section can be rendered" | ||||||
|         response = self.client.get('/simple/sitemap-simple.xml') |         response = self.client.get('/simple/sitemap-simple.xml') | ||||||
|         expected_content = """<?xml version="1.0" encoding="UTF-8"?> |         expected_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
| <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | ||||||
| </urlset> | </urlset> | ||||||
| """ % (self.base_url, date.today()) | """ % (self.base_url, date.today()) | ||||||
| @@ -92,7 +92,7 @@ class HTTPSitemapTests(SitemapTestsBase): | |||||||
|         "A simple sitemap can be rendered" |         "A simple sitemap can be rendered" | ||||||
|         response = self.client.get('/simple/sitemap.xml') |         response = self.client.get('/simple/sitemap.xml') | ||||||
|         expected_content = """<?xml version="1.0" encoding="UTF-8"?> |         expected_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
| <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | ||||||
| </urlset> | </urlset> | ||||||
| """ % (self.base_url, date.today()) | """ % (self.base_url, date.today()) | ||||||
| @@ -191,7 +191,7 @@ class HTTPSitemapTests(SitemapTestsBase): | |||||||
|         # doesn't raise an exception. |         # doesn't raise an exception. | ||||||
|         response = self.client.get('/simple/sitemap.xml') |         response = self.client.get('/simple/sitemap.xml') | ||||||
|         expected_content = """<?xml version="1.0" encoding="UTF-8"?> |         expected_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
| <url><loc>http://testserver/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | <url><loc>http://testserver/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | ||||||
| </urlset> | </urlset> | ||||||
| """ % date.today() | """ % date.today() | ||||||
| @@ -257,7 +257,7 @@ class HTTPSitemapTests(SitemapTestsBase): | |||||||
|         "A simple i18n sitemap index can be rendered" |         "A simple i18n sitemap index can be rendered" | ||||||
|         response = self.client.get('/simple/i18n.xml') |         response = self.client.get('/simple/i18n.xml') | ||||||
|         expected_content = """<?xml version="1.0" encoding="UTF-8"?> |         expected_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
| <url><loc>{0}/en/i18n/testmodel/{1}/</loc><changefreq>never</changefreq><priority>0.5</priority></url><url><loc>{0}/pt/i18n/testmodel/{1}/</loc><changefreq>never</changefreq><priority>0.5</priority></url> | <url><loc>{0}/en/i18n/testmodel/{1}/</loc><changefreq>never</changefreq><priority>0.5</priority></url><url><loc>{0}/pt/i18n/testmodel/{1}/</loc><changefreq>never</changefreq><priority>0.5</priority></url> | ||||||
| </urlset> | </urlset> | ||||||
| """.format(self.base_url, self.i18n_model.pk) | """.format(self.base_url, self.i18n_model.pk) | ||||||
| @@ -266,7 +266,7 @@ class HTTPSitemapTests(SitemapTestsBase): | |||||||
|     def test_sitemap_without_entries(self): |     def test_sitemap_without_entries(self): | ||||||
|         response = self.client.get('/sitemap-without-entries/sitemap.xml') |         response = self.client.get('/sitemap-without-entries/sitemap.xml') | ||||||
|         expected_content = """<?xml version="1.0" encoding="UTF-8"?> |         expected_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
|  |  | ||||||
| </urlset>""" | </urlset>""" | ||||||
|         self.assertXMLEqual(response.content.decode(), expected_content) |         self.assertXMLEqual(response.content.decode(), expected_content) | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ class HTTPSSitemapTests(SitemapTestsBase): | |||||||
|         "A secure sitemap section can be rendered" |         "A secure sitemap section can be rendered" | ||||||
|         response = self.client.get('/secure/sitemap-simple.xml') |         response = self.client.get('/secure/sitemap-simple.xml') | ||||||
|         expected_content = """<?xml version="1.0" encoding="UTF-8"?> |         expected_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
| <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | ||||||
| </urlset> | </urlset> | ||||||
| """ % (self.base_url, date.today()) | """ % (self.base_url, date.today()) | ||||||
| @@ -48,7 +48,7 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase): | |||||||
|         "A sitemap section requested in HTTPS is rendered with HTTPS links" |         "A sitemap section requested in HTTPS is rendered with HTTPS links" | ||||||
|         response = self.client.get('/simple/sitemap-simple.xml', **self.extra) |         response = self.client.get('/simple/sitemap-simple.xml', **self.extra) | ||||||
|         expected_content = """<?xml version="1.0" encoding="UTF-8"?> |         expected_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||||||
| <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> | ||||||
| </urlset> | </urlset> | ||||||
| """ % (self.base_url.replace('http://', 'https://'), date.today()) | """ % (self.base_url.replace('http://', 'https://'), date.today()) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user