mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #34088 -- Fixed Sitemap.get_latest_lastmod() crash with empty items.
Bug in 480191244d.
Thanks Michal Čihař for the report.
This commit is contained in:
committed by
Mariusz Felisiak
parent
444b6da7cc
commit
5eab4d1924
@@ -114,6 +114,16 @@ class CallableLastmodFullSitemap(Sitemap):
|
||||
return obj.lastmod
|
||||
|
||||
|
||||
class CallableLastmodNoItemsSitemap(Sitemap):
|
||||
location = "/location/"
|
||||
|
||||
def items(self):
|
||||
return []
|
||||
|
||||
def lastmod(self, obj):
|
||||
return obj.lastmod
|
||||
|
||||
|
||||
class GetLatestLastmodNoneSiteMap(Sitemap):
|
||||
changefreq = "never"
|
||||
priority = 0.5
|
||||
@@ -233,6 +243,10 @@ callable_lastmod_full_sitemap = {
|
||||
"callable-lastmod": CallableLastmodFullSitemap,
|
||||
}
|
||||
|
||||
callable_lastmod_no_items_sitemap = {
|
||||
"callable-lastmod": CallableLastmodNoItemsSitemap,
|
||||
}
|
||||
|
||||
urlpatterns = [
|
||||
path("simple/index.xml", views.index, {"sitemaps": simple_sitemaps}),
|
||||
path("simple-paged/index.xml", views.index, {"sitemaps": simple_sitemaps_paged}),
|
||||
@@ -417,6 +431,11 @@ urlpatterns = [
|
||||
views.sitemap,
|
||||
{"sitemaps": callable_lastmod_full_sitemap},
|
||||
),
|
||||
path(
|
||||
"callable-lastmod-no-items/index.xml",
|
||||
views.index,
|
||||
{"sitemaps": callable_lastmod_no_items_sitemap},
|
||||
),
|
||||
path(
|
||||
"generic-lastmod/index.xml",
|
||||
views.index,
|
||||
|
||||
Reference in New Issue
Block a user