Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 Oct 31, 2012 · 3 comments

Comments

@googol7
Copy link

googol7 commented Oct 31, 2012

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
Copy link

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
Copy link

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
Copy link
Contributor

digi604 commented Jul 11, 2013

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

@digi604 digi604 closed this as completed Jul 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants