Opened 10 years ago

Last modified 10 years ago

#23403 closed Bug

Sitemap bug — at Initial Version

Reported by: Igor Koshkarov Owned by: nobody
Component: contrib.sitemaps Version: 1.7
Severity: Release blocker Keywords: date utctimetuple
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When building a sitemap I receive
jango Version: 1.7
Exception Type: AttributeError
Exception Value: 'datetime.date' object has no attribute 'utctimetuple'

Exception Location: <skipped>/Django/lib/python2.7/site-packages/django/contrib/sitemaps/views.py in sitemap, line 78

Workaround can be done as:
diff --git a/django/contrib/sitemaps/views.py b/django/contrib/sitemaps/views.py
index aa184e9..d74c55b 100644
--- a/django/contrib/sitemaps/views.py
+++ b/django/contrib/sitemaps/views.py
@@ -8,6 +8,7 @@ from django.http import Http404

from django.template.response import TemplateResponse
from django.utils import six
from django.utils.http import http_date

+from datetime import datetime


def x_robots_tag(func):

@@ -71,7 +72,7 @@ def sitemap(request, sitemaps, section=None,

raise Http404("No page '%s'" % page)

response = TemplateResponse(request, template_name, {'urlset': urls},

content_type=content_type)

  • if hasattr(site, 'latest_lastmod'):

+ if hasattr(site, 'latest_lastmod') and type(site.latest_lastmod) is datetime:

# if latest_lastmod is defined for site, set header so as
# ConditionalGetMiddleware is able to send 304 NOT MODIFIED
responseLast-Modified = http_date(

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top