Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

In Django 2.3.3 the CMSSitemap doesn't work anymore if there are cms_page records with publication_date that have a NULL value #1497

Closed
googol7 opened this Issue · 3 comments

3 participants

@googol7

Django==1.4.2
django-cms==2.3.3

Environment:

Request Method: GET
Request URL: http://dev.carusocarsharing.com/sitemap.xml

Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django_extensions',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.gis',
'django.contrib.admin',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'menus',
'sorl.thumbnail',
'cms',
'mptt',
'south',
'appmedia',
'cms.plugins.text',
'cms.plugins.picture',
'cms.plugins.link',
'cms.plugins.file',
'cms.plugins.snippet',
'cms.plugins.googlemap',
'main',
'marketplace',
'convadis',
'smart_selects',
'server',
'rpc4django',
'cmsplugin_news',
'cmsplugin_mediaelements',
'cmsplugin_faq',
'cmsplugin_textwithimage',
'cmsplugin_galleria',
'contact_form',
'djangocms_utils',
'treemenus',
'sekizai',
'reversion',
'workflows',
'permissions',
'tinymce',
'cronjobs',
'compressor')
Installed Middleware:
('django.middleware.cache.UpdateCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware')

Traceback:
File "/home/django/.virtualenvs/django14-dev/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, callback_args, *callback_kwargs) File "/home/django/.virtualenvs/django14-dev/lib/python2.7/site-packages/django/contrib/sitemaps/views.py" in sitemap
  2. protocol=req_protocol)) File "/home/django/.virtualenvs/django14-dev/lib/python2.7/site-packages/django/contrib/sitemaps/init.py" in get_urls
  3. 'lastmod': self.get('lastmod', item, None), File "/home/django/.virtualenvs/django14-dev/lib/python2.7/site-packages/django/contrib/sitemaps/__init.py" in __get
  4. return attr(obj) File "/home/django/.virtualenvs/django14-dev/lib/python2.7/site-packages/cms/sitemaps/cms_sitemap.py" in lastmod
  5. return max(modification_dates)

Exception Type: TypeError at /sitemap.xml
Exception Value: can't compare datetime.datetime to NoneType

@dbartenstein

This problem occurs when a Page is in the 'published'-state but does not have a publication_date set. How can that happen as in the save-Method of class Page publication_date is set when state is 'published'?

@dbartenstein

This issue might have to do with data not migrated from django-cms 2.0.2
Back then the publication_date was set to NULL on published pages in some cases:

# Drafts should not, unless they have been set to the future
if self.published:
        if settings.CMS_SHOW_START_DATE:
            if self.publication_date and self.publication_date <= datetime.now():
                self.publication_date = None
        else:
            self.publication_date = None

For me the solution was to set publication_date to all published pages:

orm['cms.page'].objects.filter(published=True, publication_date=None).update(publication_date=timezone.now()) 
@digi604
Collaborator

pages that get published will set the publication_date. This is probably only a upgrade issue.

@digi604 digi604 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.